Setting default printer in Win NT, and 2000 
Author Message
 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



Sun, 07 Apr 2002 03:00:00 GMT  
 Setting default printer in Win NT, and 2000
You might want to check the EnumPrinters API-call.

Johan Rosengren
Responsable Informatique
PACTA S.A.



Quote:
> 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



Mon, 08 Apr 2002 03:00:00 GMT  
 Setting default printer in Win NT, and 2000

Quote:
>My problem no arises with Win NT, and Win2000 do not use the Win.Ini file

Phil,

Are you using GetProfileString, or parsing the win.ini file yourself?

Quote:
>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,

The EnumPrinters API?

Quote:
> and how can I set each one programaticaly to be the default
>printer, all without user intervention?

I believe that WriteProfileString in the Devices section should work
on all platforms.

Dave
--
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.



Mon, 08 Apr 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Win 2000 built OCX won't load on a WIn NT or 98 system

2. SHBrowseForFolder (Win 2000 vs. Win NT)

3. System's Default Printer Settings on NT

4. Message : programm too big to fit in memory win NT/2000

5. Building NT 4.0 apps on Win 2000

6. RichEdit SetCharFormat in NT & Win 2000

7. Windows Default Printers and Default Printer Setups

8. Win 2000 vs. Win 9x

9. Print Preview won't run - have a default printer

10. Default printer in NT

11. How detecting printer default on NT

12. Getting MAC Address in WIndows 98 and NT/2000/NT

 

 
Powered by phpBB® Forum Software