共用方式為


3.1.4.9.6 RpcReadPrinter (Opnum 22)

RpcReadPrinter retrieves data from the specified job or port.

 DWORD RpcReadPrinter(
   [in] PRINTER_HANDLE hPrinter,
   [out, size_is(cbBuf)] BYTE* pBuf,
   [in] DWORD cbBuf,
   [out] DWORD* pcNoBytesRead
 );

hPrinter: A handle to a job object or port object that was opened by RpcOpenPrinter (section 3.1.4.2.2) or RpcOpenPrinterEx (section 3.1.4.2.14).

pBuf: A pointer to a buffer that receives the printer data. If the hPrinter parameter is the handle to a port object, this method returns the data that is returned by the port monitor.

This parameter can be NULL if the value of the cbBuf parameter is zero.

cbBuf: The size, in bytes, of data to be read into the buffer that is pointed to by the pBuf parameter.

pcNoBytesRead: A pointer to a variable that receives the number of bytes of data copied into the array to which pBuf points.

Return Values: This method MUST return zero (ERROR_SUCCESS) to indicate successful completion or a nonzero Windows error code to indicate failure [MS-ERREF].

Upon receiving this message, the server MUST validate parameters as follows:

  • Perform the validation steps that are specified in PRINTER_HANDLE Parameters (section 3.1.4.1.11).

  • Verify that printing of the job has not been canceled and if that verification fails, return ERROR_PRINT_CANCELLED [MS-ERREF].

  • If the value of the cbBuf parameter is not zero, verify that the pBuf parameter is not NULL.

  • Additional validation MAY<376> be performed.

If parameter validation fails, the server MUST fail the operation immediately and return a nonzero error response to the client. Otherwise, the server MUST process the message and compose a response to the client as follows:

  • If the hPrinter parameter is a job object handle, copy data from the temporary storage of the job object to the buffer pointed to by pBuf, up to the number of bytes indicated in cbBuf, or to the end of the temporary storage's data, whichever comes first.

  • If the hPrinter parameter is a port object handle, read directly from the port and copy the read data to the buffer pointed to by pBuf, up to the number of bytes indicated in cbBuf or until no more data can be read, whichever comes first. This requires that the port monitor for the port supports reading data from the port; otherwise, return ERROR_INVALID_HANDLE.<377>

  • Write the number of bytes that were copied to the variable that is pointed to by pcNoBytesRead.

  • If reading from a job object, update the read pointer, so a subsequent read continues at the correct location.

  • Return the status of the operation.