Had the following error appear on a Visual FoxPro Application running under Citrix:-
Error Number: 1957
Error message: Error accessing printer spooler.
I found out that this error was caused because sometimes FoxPro cannot determine the default printer. So a work around was to use the winspool.drv and force FoxPro to the Default Printer name.
Example code as follows (I am defaulting to Win2PDF if no printer is found as this is installed on all our Citrix clients):-
SET PRINTER TO NAME (cDefaultPrinter)
REPORT FORM "TestReport.frx" TO PRINTER PROMPT NOCONSOLE
DECLARE INTEGER GetDefaultPrinter IN winspool.drv;
STRING @ pszBuffer,;
INTEGER @ pcchBuffer
&&Return default printer name
nBufsize = 250
cPrinter = REPLICATE(Chr(0), nBufsize)
= GetDefaultPrinter(@cPrinter, @nBufsize)
cDefaultPrinter = SUBSTR(cPrinter, 1, AT(Chr(0),cPrinter)-1)
lnPrinterCount = APRINTERS(oPrinters)
FOR lnPCount = 1 TO lnPrinterCount
IF oPrinters[lnPCount,1] = 'Win2PDF'
SET PRINTER TO NAME "Win2PDF"