SetJob

BOOL SetJob(
HANDLE hPrinter,   /* handle of printer object         */
DWORD  dwJob,      /* job-identification value         */
DWORD  dwLevel,    /* structure level                  */
LPBYTE lpbJob,     /* address of job info structures   */
DWORD  dwCommand   /* job-command value                */
);
 

Pauses, resumes, cancels, or restarts the specified print job on the given printer. This function can also be used to set print job parameters such as the job priority, document name, and so forth.

hPrinter Identifies the printer.
dwJob Specifies the print job.
dwLevel Specifies the version of the structure to which lpbJob points. This value must be 0, 1, or 2.
lpbJob Points to either a JOB_INFO_1 or JOB_INFO_2 structure. If dwLevel is 0, this pointer must be NULL; if dwLevel is 1, the array contains a JOB_INFO_1 structure and if dwLevel is 2, the array contains a JOB_INFO_2 structure.
dwCommand Specifies the operation which should be performed. It can be one of the following values:
  JOB_CONTROL_CANCEL Deletes a print job.
JOB_CONTROL_PAUSE Pauses a print job.
JOB_CONTROL_RESTART Restarts a print job at the beginning of the job. A job can only be restarted if it is printing.
JOB_CONTROL_RESUME Resumes a paused print job.

The SetJob function can be used to set various job parameters by supplying a pointer to a JOB_INFO_1 or JOB_INFO_2 structure that contains the necessary data.

To remove or delete all the print jobs for a particular printer, call the SetPrinter function and set the PRINTER_CONTROL_PURGE value.

The following fields of a JOB_INFO_1 or JOB_INFO_2 structure will be ignored on a call to SetJob: JobId, pPrinterName, pMachineName, pUserName, pDrivername, Size, Submitted, and Time.

The Win32 API documentation does not define whether or not operations specified by dwCommand should be performed if dwLevel is non-zero. In the Windows 95 local Print Provider however, dwCommand operations are only performed if dwLevel is zero. This is the suggested implementation.