Set default printer programatically? 
Author Message
 Set default printer programatically?

    Hello, my friend.

    I am trying to find a way to set the default system printer
programmatically on WinNT 4.0. Consider the weirdness that follows:

        - SetPrinter() can be used to set the default printer, but only on
Win95 (see Q140560).
        - SetDefaultPrinter() can be used to set the default printer, but
only on Win2000.

    Is WinNT 4.0 the only operating system on which a default printer cannot
be set? My friend, this is lunacy. For my purposes, I only need this to work
on WinNT 4.0.

    Go in peace, my friend.

David



Mon, 03 Dec 2001 03:00:00 GMT  
 Set default printer programatically?
A very odd solution, indeed. I would never have guessed it. But it works
beautifully, yes sir!!! :)

Thank you so much for your reply!

David



Mon, 03 Dec 2001 03:00:00 GMT  
 Set default printer programatically?
David,
As advanced as the print spooler is in WinNT, it still has some
shortcomings.
One of them, as you are painfully aware, is the apparent inability to set a
default printer through the documented API's.
Here's what yak do:

// ...insert code that enum's printers & selects the default...

TCHAR szPrinterName[] = "My Printer";            // the name that you see in
the printers folder
TCHAR szDriverName[] = "XYZ Laser Printer";    // the constant name of the
driver
TCHAR szPortName[] = "LPT1:";            // the port that the printer is
attached to
wsprintf( szDefault, "%s,%s,%s", szPrinterName, szDriverName, szPortName );
WriteProfileString( TEXT("windows"), TEXT("device"), szDefault );

Strangly enough, this is how you would do it in Windows 3.1x

-Jason


Quote:
>     Hello, my friend.

>     I am trying to find a way to set the default system printer
> programmatically on WinNT 4.0. Consider the weirdness that follows:

>         - SetPrinter() can be used to set the default printer, but only on
> Win95 (see Q140560).
>         - SetDefaultPrinter() can be used to set the default printer, but
> only on Win2000.

>     Is WinNT 4.0 the only operating system on which a default printer
cannot
> be set? My friend, this is lunacy. For my purposes, I only need this to
work
> on WinNT 4.0.

>     Go in peace, my friend.

> David



Tue, 04 Dec 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Programatically change windows default printer

2. Windows Default Printers and Default Printer Setups

3. Set Default Printer

4. Set default printer

5. how to Set Default Printer

6. Q: How to set default printer bin?

7. Problems Setting the Default printer with Win32 API SDK

8. Help : How to set the default printer

9. Setting the Default Printer

10. how to Set Default Printer

11. Setting default printer via DEVMODE struct and EnumPrinters

12. Setting default printer in Win NT, and 2000

 

 
Powered by phpBB® Forum Software