Click to See Complete Forum and Search --> : Setting Default Printer in Win95/98/NT4 using C


Tommy
April 26th, 1999, 10:16 PM
I am trying to write a program in C/C++ for the win32 environment that will change a certain printer to the default printer. Any help I could get would be great!

Todd Jeffreys
April 27th, 1999, 07:10 AM
Hey Tom Salomone, Todd here ;) Checking out documentation on SetPrinter() API and here's what I have. You want a PRINTER_INFO_2 structure, to call to SetPrinter.

SetPrinter(hPrinter,2,(PRINTER_INFO_2*)&pInfo,0);

For your pInfo PRINTER_INFO_2 structure, Set the Attributes field to contain PRINTER_ATTRIBUTE_DEFAULT.

I guess a call to GetPrinter would be used to fill the PRINTER_INFO_2 structure, then just modify the Attributes (pInfo.Attributes |= PRINTER_ATTRIBUTE_DEFAULT);