Board index » delphi » How to change default printer under WinNT

How to change default printer under WinNT

Need assistance on changing the default printer under Windows NT 4.0,

I have written a function the will change the default printer under Windows
95 just as if you went to the printer folder, right-click on printer  and
checked Set as Default.

This function uses Enum printer, GetPrinter, OpenPrinter,  then
changing the attributes value in Printer_Info_5 structure to value of
PRINTER_ATTRIBUTE_DEFAULT then using SetPrinter to write changes.
Broadcast message of change to Windows.

When I run the same function in WinNT it works fine but does not make the
change.  Any ideas or suggestions??

 

Re:How to change default printer under WinNT


Quote
Charles Craig <Charles.Cr...@abbott.com> wrote:

: This function uses Enum printer, GetPrinter, OpenPrinter,  then
: changing the attributes value in Printer_Info_5 structure to value of
: PRINTER_ATTRIBUTE_DEFAULT then using SetPrinter to write changes.
: Broadcast message of change to Windows.
:  
: When I run the same function in WinNT it works fine but does not make the
: change.  Any ideas or suggestions??

  Just change the "device=" line in win.ini using the profile functions.
(If you check your win.ini file, you'll see that the line's not even
there. What NT does is intercept the calls, and performs the appropriate
registry modifications "automagically," which is why you have to use
profile functions, rather than editing the file directly. AFAIK, this is
the only method that's portable across all versions of Windows.)

--
Mike Swaim, Avatar of Chaos: Disclaimer:I sometimes lie.
Home: sw...@c-com.net
Alum: sw...@rice.edu  Quote: "Boingie"^4 Y,W&D

Other Threads