EnumJobs function
The EnumJobs function retrieves information about a specified set of print jobs for a specified printer.
Syntax
BOOL EnumJobs(
_In_ HANDLE hPrinter,
_In_ DWORD FirstJob,
_In_ DWORD NoJobs,
_In_ DWORD Level,
_Out_ LPBYTE pJob,
_In_ DWORD cbBuf,
_Out_ LPDWORD pcbNeeded,
_Out_ LPDWORD pcReturned
);
Parameters
-
hPrinter [in]
-
A handle to the printer object whose print jobs the function enumerates. Use the OpenPrinter or AddPrinter function to retrieve a printer handle.
-
FirstJob [in]
-
The zero-based position within the print queue of the first print job to enumerate. For example, a value of 0 specifies that enumeration should begin at the first print job in the print queue; a value of 9 specifies that enumeration should begin at the tenth print job in the print queue.
-
NoJobs [in]
-
The total number of print jobs to enumerate.
-
Level [in]
-
The type of information returned in the pJob buffer.
Value Meaning - 1
pJob receives an array of JOB_INFO_1 structures - 2
pJob receives an array of JOB_INFO_2 structures - 3
pJob receives an array of JOB_INFO_3 structures -
pJob [out]
-
A pointer to a buffer that receives an array of JOB_INFO_1, JOB_INFO_2, or JOB_INFO_3 structures. The buffer must be large enough to receive the array of structures and any strings or other data to which the structure members point.
To determine the required buffer size, call EnumJobs with cbBuf set to zero. EnumJobs fails, GetLastError returns ERROR_INSUFFICIENT_BUFFER, and the pcbNeeded parameter returns the size, in bytes, of the buffer required to hold the array of structures and their data.
-
cbBuf [in]
-
The size, in bytes, of the pJob buffer.
-
pcbNeeded [out]
-
A pointer to a variable that receives the number of bytes copied if the function succeeds. If the function fails, the variable receives the number of bytes required.
-
pcReturned [out]
-
A pointer to a variable that receives the number of JOB_INFO_1, JOB_INFO_2, or JOB_INFO_3 structures returned in the pJob buffer.
Return value
If the function succeeds, the return value is a nonzero value.
If the function fails, the return value is zero.
Remarks
Note
This is a blocking or synchronous function and might not return immediately. How quickly this function returns depends on run-time factors such as network status, print server configuration, and printer driver implementation factors that are difficult to predict when writing an application. Calling this function from a thread that manages interaction with the user interface could make the application appear to be unresponsive.
The JOB_INFO_1 structure contains general print-job information; the JOB_INFO_2 structure has much more detailed information. The JOB_INFO_3 structure contains information about how jobs are linked.
To determine the number of print jobs in the printer queue, call the GetPrinter function with the Level parameter set to 2.
Requirements
Requirement | Value |
---|---|
Minimum supported client |
Windows 2000 Professional [desktop apps only] |
Minimum supported server |
Windows 2000 Server [desktop apps only] |
Header |
|
Library |
|
DLL |
|
Unicode and ANSI names |
EnumJobsW (Unicode) and EnumJobsA (ANSI) |