The SetJob function pauses, resumes, cancels, or restarts a print job on a specified printer. You can also use the SetJob function to set print job parameters, such as the print job priority and the document name.
Windows 95: You can use the SetJob function to give a command to a print job, or to set print job parameters, but you can not do both in the same call. Thus, when the Command parameter is non-zero, the function ignores the Level and pJob parameters. To set print job parameters, you must set Command to 0.
Windows NT: You can use the SetJob function to give a command to a print job, or to set print job parameters, or you can do both in the same call. The value of the Command parameter does not affect how the function uses the Level and pJob parameters.
BOOL SetJob(
HANDLE hPrinter, // handle to printer object
DWORD JobId, // print job identifier
DWORD Level, // specifies type of job information structure
LPBYTE pJob, // pointer to job information structure
DWORD Command // job command value
);
Windows NT: If the Level parameter is set to 3, the JobId parameter must match the JobId member of the JOB_INFO_3 structure pointed to by pJob.
When you set Level to 0, pJob should be NULL. Use these values when you are not setting any print job parameters.
Windows NT: You can also set the Level parameter to 3.
Windows 95: The function pays attention to this parameter only if the Command parameter is 0. If Command is non-zero, the function ignores this parameter and the pJob parameter.
Windows NT: pJob can also point to a JOB_INFO_3 structure.
If the Level parameter is 0, pJob should be NULL.
If the Level parameter is 1, pJob should point to a JOB_INFO_1 structure. If the Level parameter is 2, pJob should point to a JOB_INFO_2 structure.
Windows NT: If the Level parameter is 3, pJob should point to a JOB_INFO_3 structure. You must have JOB_ACCESS_ADMINISTER access permission for the jobs specified by the JobId and NextJobId members of the JOB_INFO_3 structure.
Windows 95: The function pays attention to this parameter only if the Command parameter is 0. If Command is non-zero, the function ignores this parameter and the Level parameter.
Value | Meaning |
---|---|
JOB_CONTROL_CANCEL | Delete the print job. |
JOB_CONTROL_PAUSE | Pause the print job. |
JOB_CONTROL_RESTART | Restart the print job. A job can only be restarted if it was printing. |
JOB_CONTROL_RESUME | Resume a paused print job. |
Windows 95: If you are using the SetJob function to set print job parameters, you must set the Command parameter to 0.
Windows NT: You can use the same call to the SetJob function to set print job parameters and to give a command to a print job. Thus, Command does not need to be 0 if you are setting print job parameters, although it can be.
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
You can use the SetJob function to set various print job parameters by supplying a pointer to a JOB_INFO_1, JOB_INFO_2, or JOB_INFO_3 structure that contains the necessary data.
Windows 95: When you use the function to set print job parameters, you must set the Command parameter to 0.
To remove or delete all of the print jobs for a particular printer, call the SetPrinter function with its Command parameter set to PRINTER_CONTROL_PURGE.
The following members of a JOB_INFO_1 or JOB_INFO_2 structure are ignored on a call to SetJob:
JobId, pPrinterName, pMachineName, pDrivername, Size, Submitted, and Time.
You must have PRINTER_ACCESS_ADMINISTER access permission for a printer in order to change a print job's position in the print queue.
If you do not want to set a print job's position in the print queue, you should set the Position member of the JOB_INFO_1 or JOB_INFO_2 structure to JOB_POSITION_UNSPECIFIED.
Windows NT: Use the SetJob function with the JOB_INFO_3 structure to link together a set of print jobs. This can be useful in situations where a single document consists of several parts that you want to render separately.
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in winspool.h.
Import Library: Use winspool.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT.
Printing and Print Spooler Overview, Printing and Print Spooler Functions, AddJob, GetJob, OpenPrinter, SetPrinter, JOB_INFO_1, JOB_INFO_2, JOB_INFO_3