Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

SetJob (winspool)
 
.
Summary
Pauses, resumes, cancels, or restarts a print job on a specified printer.

C# Signature:

[DllImport("winspool.drv", EntryPoint="SetJob")]
static extern int SetJobA(IntPtr hPrinter, int JobId,
   int Level, ref byte pJob, int Command_Renamed);

VB Signature:

Declare Function SetJob Lib "winspool.drv" (hPrinter As IntPtr, JobId As Integer,
   Level As Integer, ByRef pJob As Byte, Command_Renamed As Integer)

User-Defined Types:

    public struct Printer_Defaults
        {
            public int pDatatype;
            public int pDevMode;
            public int DesiredAccess;
        }

        private enum Job_Control
        {
            Pause = 1,
            Resume = 2,
            Cancel = 3,
            Restart = 4,
            Delete = 5
        }

Notes:

Tips & Tricks:

How to cancel a print job:

int pHandle = 0;

Printer_Defaults defaults = new Printer_Defaults();

byte b = 0;

OpenPrinterA(printerName, ref pHandle, ref defaults);

SetJobA(pHandle, (int)jobID, 0, ref b, (int)Job_Control.Cancel);

ClosePrinter(pHandle);

Sample Code:

Please add some!

Alternative Managed API:

The System.Management API allows for lots of printer stuff, but doesn't let you delete a print job in Win2K.

Documentation
SetJob on MSDN

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Find References
Show Printable Version
Revisions