Windows GDI
EnumJobs
The EnumJobs function retrieves information about a specified set of print jobs for a specified printer.
BOOL EnumJobs(
HANDLE hPrinter, // handle to printer object
DWORD FirstJob, // index of first job
DWORD NoJobs, // number of jobs to enumerate
DWORD Level, // information level
LPBYTE pJob, // job information buffer
DWORD cbBuf, // size of job information buffer
LPDWORD pcbNeeded, // bytes received or required
LPDWORD pcReturned // number of jobs received
);
Parameters
- hPrinter
- [in] Handle to the printer object whose print jobs the function enumerates. Use the OpenPrinter or AddPrinter function to retrieve a printer handle.
- FirstJob
- [in] Specifies 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] Specifies the total number of print jobs to enumerate.
- Level
- [in] Specifies 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] 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] Specifies the size, in bytes, of the pJob buffer.
- pcbNeeded
- [out] 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] 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 Values
If the function succeeds, the return value is a nonzero value.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Remarks
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.
Windows NT/2000/XP/Vista: Included in Windows NT 3.1 and later.
Windows 95/98/Me: Included in Windows 95 and later.
Header: Declared in Winspool.h; include Windows.h.
Library: Use Winspool.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000/XP.
See Also
Printing and Print Spooler Overview, Printing and Print Spooler Functions, GetJob, GetPrinter, JOB_INFO_1, JOB_INFO_2, JOB_INFO_3, OpenPrinter, SetJob