Was this page helpful?
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

3.2.4.2.3 Enumerating Jobs on a Printer

To enumerate the jobs that are currently queued to a printer, the client MUST perform the following steps:

  1. Invoke RpcOpenPrinter, supplying the name of the target printer in the pPrinterName parameter and an AccessRequired value that includes PRINTER_ACCESS_USE.

  2. Using the printer handle that was obtained from RpcOpenPrinter, the client MUST:

    1. Set a local job position context to the desired starting index, typically zero.

    2. Set a local number of jobs to return in a single operation.<472>

    3. Until an RpcEnumJobs call returns with a success status and a pcReturned pointing to a value of zero, or until the expected set of jobs has been returned, the client MUST:

      1. Invoke RpcEnumJobs, supplying the job position context in FirstJob, the number of jobs to return in a call in NoJobs, the desired information level in Level, a pointer to the job information buffer in pJob, the size of the job information buffer in cbBuf, a pointer to a variable to store the required buffer size in pcbNeeded, and a pointer to a variable to store the number of job information structures returned in pcReturned.

      2. While RpcEnumJobs returns with ERROR_INSUFFICIENT_BUFFER, as specified in [MS-ERREF], the client MUST:

        1. Allocate a new job information buffer with the size returned in pcbNeeded.

        2. Invoke RpcEnumJobs, supplying the job position context in FirstJob, the number of jobs to return in a call in NoJobs, the desired information level in Level, a pointer to the job information buffer in pJob, the size of the job information buffer in cbBuf, a pointer to a variable to store the required buffer size in pcbNeeded, and a pointer to a variable to store the number of job information structures in pcReturned.

        Note: Because the number of jobs can change at any time, the client SHOULD be prepared to receive ERROR_INSUFFICIENT_BUFFER even after allocating the correct buffer size the first time.

      3. Increase the local job position context by the value supplied in pcReturned.

  3. The client SHOULD invoke RpcClosePrinter with the printer handle obtained from RpcOpenPrinter or SHOULD repeat step 2 if there are further job enumeration requests to make.

Show:
© 2016 Microsoft