Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
GetPrinterDriver() problem
Message
From
24/08/2004 18:42:24
 
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00936149
Message ID:
00936157
Views:
38
The error returned from GetLastError() is
1780 = "A null reference pointer was passed to the stub."

i have tried setting the second parameter to 'chr(0)' as specified in help ("...Pointer to a null-terminated string that specifies the environment (for example, "Windows NT x86", ...")

but the result is the same. the function returns 0, and the bufferlength needed is not returned.



>You've to check error generated by GetPrinterDriver to make sure that it's 'buffer too small error' not something else.
>* Get the size of the buffer required
>IF GetPrinterDriver(PrHandel, "", 1, "", 0, @RecvdBufferLen) = 0
>	IF GetLastError() <> 122   && The buffer too small error
>                *   Do something
>		RETURN .F.
>	ENDIF
>ENDIF
>
See Enumerating printer forms under Windows NT/2K/XP FAQ #22445 for how to handle API errors.
>
>>Why would the following not return the size need for the returned data (windows xp, Vfp 6 Sp5)? the printer is a network printer, but also installed on this machine. I am trying to get the name of the PrinterDrive installed for this printer.
>>PrHandel = 0
>>?OpenPrinter("\\print01\Plan1", @PrHandel, 0)
>>?PrHandel
>>
>>RecvdBufferLen	= 0
>>
>>?GetPrinterDriver(PrHandel, "", 1, "", 0, @RecvdBufferLen)
>>
>>Test		= space(RecvdBufferLen)
>>*EnvString		= "Windows XP"
>>EnvString		= ""
>>
>>?GetPrinterDriver(PrHandel, EnvString, 1, @Test, RecvdBufferLen, @RecvdBufferLen)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform