Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
*:* FPD + Win/NT -> WSH (Network redirection of printers & Calling DLL's build with VB 5.0)
Some time ago I read an interesting article in Win/NT Mag. concerning WSH = Windows Scripting Host. WSH can be downloaded for free from the microsoft web. As I still have a lot of FPD26 code in production (no time to rewrite) I saw an opertunity to integrate FPD26 tighter into the operating system and integrate FPD26 with other Win32 applications written in VB by using WSH.
Problem 1 I solved: Network redirection of printers... Shelling out of FPD26 towards the command prompt and calling the NET USE command never was a good solution. So I now use the following code:
sPrtPort = "LPT1:"
sPrtMap = "\\PRTSERVER\PRINTER1"
OutChan = FCREATE("C:\FOXPRO\WSHPrint.VBS")
IF OutChan > 0
=FPUT(OutChan,'Set WshNetwork = WScript.CreateObject("WScript.Network")')
=FPUT(OutChan,'On Error Resume Next')
=FPUT(OutChan,'WshNetwork.RemovePrinterConnection "' + sPrtPort + '"')
=FPUT(OutChan,'WshNetwork.AddPrinterConnection "' + sPrtPort + '", "' + sPrtMap + '"')
=FCLOSE(OutChan)
Tmp_4 = "RUN /0 CScript C:\FOXPRO\WSHPrint.VBS //B //NoLogo //T:60"
&Tmp_4
SET PRINTER TO &sPrtPort
ENDIF
The above example is an extract of the full code I have under WSH. You can add checking of the printer connection so that you don't add new code. In a comparable way you can add shortcuts to the desktop... see [URL unfurl="true"]www.microsoft.com\management[/URL] and check for WSH.
Problem 2 I solved: Calling DLL's build with VB 5.0 to access information stored in *.MDB or other non accessible DB's from FPD26.
MS Office (Excel, Word) is used by several persons on a daily basis. The macro language build into Excel / Word is, I'm sorry to say, not VFP but Visual Basic 5.0. So several programs (macros) have been written in the past to access databases. Through time the code became so big that I had to start using VB 5.0. In VB 5.0 I compiled into DLL's (ActiveX InProcess Servers) which were then called from Excel and Word and from standalone applications. After a short while I had two different systems up and running. One system in FPD26 which I was rewriting slowly but which wasn't able to communicate directly with the new code running under Excel / Word. So with WSH I can now communicate.
With the above example I call the shipment print procedure written in VB out of FPD26. The whole process is transparent towards the users. The users doesn't notice any difference except that now the printouts of the FPD26 and the VB code are identical. I've also experience that the overhead created by the FPD26 and the WSH link is neglectible.
OutChan = FCREATE("C:\FOXPRO\WSHPInst.VBS")
IF OutChan > 0
=FPUT(OutChan,'Set oPrt = WScript.CreateObject("PrintEngine.ShipmentPrint")')
=FPUT(OutChan,'oPrt.ShipmentPrint "' + m.ShipMent + '"')
=FPUT(OutChan,'WScript.DisconnectObject oPrt')
=FPUT(OutChan,'Set oPrt = Nothing')
=FCLOSE(OutChan)
Tmp_4 = "RUN /0 CScript C:\FOXPRO\WSHPInst.VBS //B //NoLogo //T:60"
&Tmp_4
ENDIF
Suddenly my FPD26 has gained value because it can communicate not only with the operating system but also because I can now call Dll's in an easy way.
I though it was necessary to share this piece of information with you as I've been looking for a WSH solution for quite some time. Also this discussion group has been an overwhelming source of information for me for many years now.
Kind regards,
bibi,
Donald Neyt.
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\PrinterPorts]
"HPLJ4100"="winspool,Ne01:,15,45"
"Fax Driver"="winspool,Ne02:,15,45"
"Fax"="winspool,Ne03:,15,45"
MyCmd = "RUN /0 regedit C:\temp\PrtPorts.reg"
&MyCmd