Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Needed: printer drivers from Win 2000 Registry.

Status
Not open for further replies.

Sunishine

Programmer
Oct 19, 2001
4
US
I have a deployed report (i.e. invoice) written in Crystal Reports 6.0 that uses VB Script to call it, which is in turn called from a C++ program. CR requires the printer name, driver name, and the port name of the network printer to be used to print the report passed in as parms. Under win 98 this is easily obtained from the c:\windows\win.ini file.

The application process is to display all loaded drivers in a list box, and the user selects the printer to use to print the invoice. It may or not be the default printer. The printer information is then written to another .ini file for use later at actual print time by the VB script that calls the CR Report.

However, Windows 2000 no longer has the windows folder, nor the win.ini file that contains the printer drivers. I cannot determine how to obtain the DRIVER NAME from the registry. I have been able to get the other information, but without the driver name, it always goes to the Windows Default printer.

Does anyone know how I can get this information using VB script, thus enabling me to display it so the user can choose the printer, store it someplace, retrieve it at print time and pass it on to my Crystal runtime report?

Thank you!
 
Check out the WshNetwork object and the EnumPrinterConnection method for vbscript.
 
Well, this is what I used to get the printer name, but it doesn't return the actual printer driver that crystal requires. Upon further research into the Windows Script help, I see that driver name is ignored if the script is run on windows 2000; so I may be dead in the water.

Thanks for the response!
 
Hello, Sunishine.

It is possible to use WshNetwork to enumerate the existing printer portfolio and then set the the default printer to one your desired by matching the enumerated returns with the string of printer name your desire to match and use.

But, WshNetwork seems not able to determine what is the default printer at present the system is set. I think that's this latter data you want to determine.

To determine the default printer at present, I think using wsh.RegRead is a viable direct approach. Ironically, reading of this data from win2000 seems to be much simpler than from win9x machine. For win9x you need enumerate registry subkeys which wscript shell does not have. You need something else, like regobj or wmi. For win2000, you do not need enumeration, a direct approach works.

Look into your win2000 machine registry key:

[HKEY_CURRENT_USER\Software\Microsoft\WindowsNT\CurrentVersion\Windows]

under which there is an entry "Device" of REG_SZ format:
&quot;Device&quot; = <the default printer signature string>

You can read the default printer from the value, ie, the right hand side of it.

regards - tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top