Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Resetting the Windows Default Printer
Message
From
13/11/2001 14:30:31
 
 
To
13/11/2001 10:20:08
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00580881
Message ID:
00581065
Views:
16
>In VFP 6.0, is there a way to reset the Windows Default Printer in code rather than using a dialog box?
>
>We have a function that saves the current Windows Default Printer to a variable, uses the Microsoft Common Dialog Box to select a new Windows Default Printer for printing a report, then I need to reset the Windows Default Printer back to the original value. So far, I have not found a way to do it.
>

The Windows Script Host's Wscript.Network Object has a SetDefaultPrinter() method that would do this. Assuming you had a printer named 'MyHPLaser':
oWSHNet = CREATEOBJ('Wscript.Network')
oWSHNet.SetDefaultPrinter('MyHPLaser')
oWSHNet = NULL
You can specify a printer name, a physical port, or a UNC - the catch is that the driver for the printer must already be installed.


>We need to use the Microsoft Common Dialog Box so we can enable/disable certain controls, and be able to pass a default number of copies into the dialog.
>
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform