The Windows Scripting Host - dFPUG-Portal
The Windows Scripting Host - dFPUG-Portal
The Windows Scripting Host - dFPUG-Portal
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Print Article<br />
or<br />
WSHNetwork.RemovePrinterConnection("\\server\ ;<br />
printer_share",.T.,.T.)<br />
SetDefaultPrinter(strName)<br />
This method sets the default printer:<br />
WSHNetwork.SetDefaultPrinter("\\server\printer_share")<br />
Conclusion<br />
<strong>The</strong> ability to work with the <strong>Windows</strong> Registry, create desktop shortcuts, and map and view network resources all required you<br />
to know how to use extensive <strong>Windows</strong> API functions, or a third-party DLL. <strong>The</strong> WSH provides a simple and elegant set of<br />
objects with simple interfaces that allow you to accomplish many tasks. Perhaps your application requires special Registry<br />
entries. Perhaps you've been tasked with developing a utility that modifies the default printer or dynamically maps network<br />
resources. All of these tasks can easily be accomplished with the WSH.<br />
<strong>The</strong> good news is that the WSH will be a standard part of the operating system beginning with <strong>Windows</strong> 2000. Until the<br />
release of <strong>Windows</strong> 2000, you'll need to make sure the WSH is installed on any client workstation that uses your application.<br />
One approach to this problem is to add a method to your application class that tests to see whether the WSH is installed. If it<br />
isn't, prompt the user through the process of both downloading and installing the WSH.<br />
<strong>The</strong> <strong>Windows</strong> <strong>Scripting</strong> <strong>Host</strong> -- yet another valuable tool to add to your toolbox!<br />
Sidebar: VFP Bug Alert!<br />
While the documentation states that the second argument in the Popup method specifies a timeout interval in which the<br />
MessageBox will be cleared, it doesn't work in VFP. I tested this code in Visual Basic, and the expected behavior occurred.<br />
This behavior has been reported to the VFP team and hopefully will be fixed in the next release.<br />
<strong>The</strong> WSH Shell object provides three methods for working with the <strong>Windows</strong> Registry:<br />
RegWrite(strName, anyValue, [strType] )<br />
RegDelete(strName)<br />
RegRead(strName)<br />
With these methods, entries can be created, written, read, and deleted. If you attempt to write to a key that doesn't exist, the<br />
key will be created. <strong>The</strong> code in Listing 1 illustrates how these three methods work (click on the Listing link for the<br />
code).<br />
http://foxtalknewsletter.com/ME2/Audiences/Segments/Publications/Print.asp?Module=...<br />
Seite 6 von 6<br />
31.01.06