FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Find default Printer?
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Find default Printer?
Posted: Wed Mar 04, 2015 03:40 PM

Hi,

How can I find out default printer name?

I tried Getdefaultprinter() but it crashed.

I use msvc 2012 and harbour.

Thanks,

Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Find default Printer?
Posted: Wed Mar 04, 2015 04:09 PM
Hakan,

try this:

Code (fw): Select all Collapse
? PRNGETNAME()


EMG
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: Find default Printer?
Posted: Wed Mar 04, 2015 05:16 PM
Enrico Maria Giordano wrote:Hakan,

try this:

Code (fw): Select all Collapse
? PRNGETNAME()


EMG


Thank you Enrico,

I works OK.
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Find default Printer?
Posted: Thu Mar 05, 2015 12:41 AM
I just tested getDefaultPrinter() here and it works fine with Windows 8.1, FW13.04, xHarbour and Borland 5.82.

prnGetName() returns the current printer, which may, or may not, be the Windows default printer.

When any app is run, the current printer of that app is the Windows default printer. However, via any printer setup dialog, or via code the app may change the current printer for that app. So, when prnGetName() you will get the Windows default printer, unless or until either the code or the user changes it.

I have this code in my notes for getting the Windows default printer. I have tested it just now and it works.

Code (fw): Select all Collapse
// Returns the Windows default printer
function getPrinter()
   local cString
   cString:= GetProfString( "windows", "device" , "" )
   cString:= left(cString,at(",",cString)-1)
return cString
Hope it works for you.

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: Find default Printer?
Posted: Thu Mar 05, 2015 07:37 AM

Thank you James, Enrico.

Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06

Continue the discussion