Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DRIVER_INFO_2
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
Miscellaneous
Thread ID:
00186207
Message ID:
00186317
Views:
14
>How can I mimick the structure DRIVER_INFO_2 for use by the AddPrinterDriver function? The typedef is as follows:
>
>typedef struct _DRIVER_INFO_2 { // dri2
> DWORD cVersion;
> LPTSTR pName;
> LPTSTR pEnvironment;
> LPTSTR pDriverPath;
> LPTSTR pDataFile;
> LPTSTR pConfigFile;
>} DRIVER_INFO_2;
>
>I've tried using the following:
>drvString = "4.00" + chr(0) + "Generic" + chr(0) + "" + chr(0) + "tty.drv" + chr(0) + "" + chr(0) + "iconlib.dll"
>but even though the function returns .T., the driver is not actually installed.
>
>thanks!

You can allocate the structure itself in a VFP string, but the pointers to strings need to be allocated in memory outside the VFP memory space. My CLSHEAP class could handle the allocations, as could Paul Tatavu's POINTERS class. Using CLSHEAP:
SET PROCEDURE TO CLSHEAP.PRG
oHeap = CREATEOBJ('Heap')
nNameBuffer = oHeap.Alloc(SizeOfName)
oHeap.CopyTo(nNameBuffer,cMyNameString+CHR(0))
nEnvBuffer = oHeap.Alloc(SizeOfEnvironment)
oHeap.CopyTo(nEnvBuffer,cMyEnvString + CHR(0))
nDriverPath = oHeap.Alloc(SizeOfDriverPath)
oHeap.CopyTo(nDriverPath,cPath + CHR(0))
nFileBuff = oHeap.Alloc(SizeOfFilename)
oHeap.CopyTo(nFileBuff,cFilename + CHR(0))
nConfig = oHeap.Alloc(SizeOfConfigFilename)
oHeap.CopyTo(nConfig,cConfigFilename + CHR(0))
cDriverInfo2 = NumTODWORD(nVersion) + ;
               NumToDWORD(nNameBuffer) + ;
               NumToDWORD(nEnvBuffer) + ;
               NumToDWORD(nDriverPath) + ;
               NumTODWORD(nFileBuff) + ;
               NumToDWORD(nConfig)
When you've finished, invoke oHeap.Dealloc against whatever you've finished with; releasing oHeap (ie oheap = NULL) will release all remain allocs and release the heap owned by the object.
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
Next
Reply
Map
View

Click here to load this message in the networking platform