Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
New printer showing up in error logs
Message
From
31/03/2021 14:37:16
Mike Yearwood
Toronto, Ontario, Canada
 
 
To
31/03/2021 14:27:22
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01679388
Message ID:
01679389
Views:
54
>Hi all,
>
>In a print to pdf routine, where I change the output to a pdf driver (Amyuni), I capture the old printer before doing the switch and then after the pdf is generated, I switch back to the original.
>
>I am using a Win32 api call to set and restore the printer (as that was more reliable when users were logged in via a terminal server) e.g.
>
>
>DECLARE LONG SetDefaultPrinter IN WinSpool.drv STRING tcPrinterName
>lnResult = SetDefaultPrinter(tcPrinterName)
>
>
>The errors are all showing up when trying to set the printer back to a printer named "Send To Preview". Of course, this "printer" does not exist in the printers list. Anyone know if MSFT is firing some virtual printer driver to do previews and then Windows is leaving that as the default printer after the user has finished (e.g. maybe the new preview window when printing from a website).
>
>Albert

Hi Albert

I've not see the Send To Preview thing. We only recently switched to Win 10.

The way we do that is
lcOldPrinter=SET("printer",3)
.
.
.
set printer to name (m.lcOldPrinter)
By the way, if you create a SetDefaultPrinter.prg like this:

SetDefaultPrinter.prg
lparameters tcPrinterName
DECLARE LONG SetDefaultPrinter IN WinSpool.drv STRING tcPrinterName
RETURN SetDefaultPrinter(m.tcPrinterName)
Then you won't have to do the declare each time. All you'll have to do is
SetDefaultPrinter(lcPrinterName)
The first time Fox runs the SetDefaultPrinter .PRG. Once that runs one time, all subsequent calls will be directed to the API.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform