Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Delete all Print Jobs from a print queue
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP
Miscellaneous
Thread ID:
01164453
Message ID:
01164465
Views:
11
You have to have the correct permissions to change the global print settings for the network printer, otherwise you'll receive an "Access Denied" error message on the OpenPrinter().

>I want to delete all Print Jobs from a print queue if a user decides to abort a print job. The following code to access the default printer works fine with the local printer connected to my machine. However, I get an error message ‘Access denied’ when my default printer is a network shared printer.
>
>The code:
>-----------------------------------------------------------------------
>#DEFINE PRINTER_ACCESS_ADMINISTER 4
>
>* Open a Pinter with proper access rights
>lcPrDef = REPLICATE(CHR(0),8) + CHR(PRINTER_ACCESS_ADMINISTER) + REPLICATE(CHR(0),3)
>lnOK = OpenPrinter( tcPrinterName, @lnHandle, lcPrDef
>
>IF lnOK = 0 THEN
> lcErrorTxt = ApiError()
> WAIT WINDOW NOWAIT "Cannot Open Printer " + tcPrinterName + CHR(13) + lcErrorTxt
> RETURN -1
>ENDIF
>----------------------------------------------------------------------------
>
>Is there any way to get around this problem? Or how do I cancel printing from a network printer programmatically?
>
>Thanks.
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform