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
> * 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)