Find default Printer?

Find default Printer?

Postby Horizon » Wed Mar 04, 2015 3: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.04
Horizon
 
Posts: 1297
Joined: Fri May 23, 2008 1:33 pm

Re: Find default Printer?

Postby Enrico Maria Giordano » Wed Mar 04, 2015 4:09 pm

Hakan,

try this:

Code: Select all  Expand view
? PRNGETNAME()


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8378
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Find default Printer?

Postby Horizon » Wed Mar 04, 2015 5:16 pm

Enrico Maria Giordano wrote:Hakan,

try this:

Code: Select all  Expand view
? PRNGETNAME()


EMG


Thank you Enrico,

I works OK.
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1297
Joined: Fri May 23, 2008 1:33 pm

Re: Find default Printer?

Postby James Bott » 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: Select all  Expand view
// 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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Find default Printer?

Postby Horizon » Thu Mar 05, 2015 7:37 am

Thank you James, Enrico.
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1297
Joined: Fri May 23, 2008 1:33 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 39 guests