Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
GetPrinterDriver() Convert Return String
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00936309
Message ID:
00936362
Views:
20
Well, it's really messy procedure considering that FoxPro has no straight ways to get string content from pointer.
*|typedef struct _DRIVER_INFO_2 { 
*|  DWORD  cVersion;     0:4 
*|  LPTSTR pName;        4:4 
*|  LPTSTR pEnvironment; 8:4 
*|  LPTSTR pDriverPath;  12:4 
*|  LPTSTR pDataFile;    16:4 
*|  LPTSTR pConfigFile;  20:4 
*|} DRIVER_INFO_2, *PDRIVER_INFO_2; 24 bytes 
pName contains memory address of a string that ends with zero byte. This address (I'd even call it "this @#$@$! address") is stored inside the DRIVER_INFO_ buffer that functions like GetPrinterDriver or EnumPrinterDrivers returns as a number, say, pBuffer.

When you get this pBuffer, copy content of it to FoxPro string, say cBuffer, using CopyMemory API function. Then obtain pName value and subtract pBuffer to get offset in cBuffer.

Then start reading from this offset char by char until you get a zero (Chr(0)).

On my web site (members area) I have a code sample showing how to parse DRIVER_INFO_2:

Enumerating printer drivers installed
http://www.news2news.com/vfp/?example=82&function=124
Previous
Reply
Map
View

Click here to load this message in the networking platform