
Setting default printer in Win NT, and 2000
I have been programming for several years now, but only in DOS, and Win95/98
platforms. My current Win32 program needs to be able to run on NT, and Win
200, but I have come across a problem in the way I was printing before.
My application prints to several printers, and in the Win 95/98 environment,
I was reading all the printer names from
HKEY_LOCAL_MACHINE\System\CurrentControlSet\control\Print\Printers, then
using RegEnumKeyEx to get the names. Then when I had to print, i used the
[DEVICES] area in the Win.ini to get the printer info, and set the DEVICE
value to the printer(thus changing the default printer, to my new printer),
I would then print whatever it was I was printing, and then set the original
printer back to the default again.(long winded eh?)
My problem no arises with Win NT, and Win2000 do not use the Win.Ini file
for thisa information, and network printer are not strored in the same
format in the registry either. So my question is How can I get a list of all
the installed printer on a particular machine, both network, and local
printers, and how can I set each one programaticaly to be the default
printer, all without user intervention?
If anyone could help me here, it would be much appreciated, if you need an
example piece of code as to what I am doing now, I can provide that as well.
Thanks
Phil