SetJob
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 |
); |
|
Parameters
hPrinter
Handle to the
printer object of interest.
JobId
Identifier
that specifies the print job. You obtain a print job identifier by calling the AddJob
Windows
NT: If the Level parameter is
set to 3, the JobId parameter must match the JobId member of the JOB_INFO_3
Level
Specifies the
type of job information structure pointed to by the pJob parameter. You
can set the Level parameter to 0, 1, or 2.
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.
pJob
Pointer to a JOB_INFO_1
Windows
NT: pJob can also point to a JOB_INFO_3
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
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.
Command
Specifies the
print job operation to perform. You can use one of the following values:
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.
Return Values
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
Remarks
You can use
the SetJob function to set various print job parameters by supplying a
pointer to a JOB_INFO_1
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.
See Also