Partager via


3.1.4.9.8 RpcFlushPrinter (Opnum 96)

RpcFlushPrinter is used by printer drivers to send a buffer of bytes to a specified port to cleanly abort a print job.<378> It also allows delaying the I/O line to the printer.

 DWORD RpcFlushPrinter(
   [in] PRINTER_HANDLE hPrinter,
   [in, size_is(cbBuf)] BYTE* pBuf,
   [in] DWORD cbBuf,
   [out] DWORD* pcWritten,
   [in] DWORD cSleep
 );

hPrinter: A handle to a 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 the array of bytes containing the data to be written to the printer. This parameter can be NULL if the value of the cbBuf parameter is zero.

cbBuf: The size, in bytes, of the array pointed to by the pBuf parameter.

pcWritten: A pointer to a variable that receives the number of bytes of data that were written to the printer.

cSleep: The time, in milliseconds, to delay the I/O line to the printer port. A value of zero indicates no delay.

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). This method SHOULD assume that the handle to the port object can be used without further access checks.

  • Verify that a previous RpcWritePrinter (section 3.1.4.9.3) on the same port object has failed due to job cancellation, and if that verification fails, return ERROR_INVALID_HANDLE as specified in [MS-ERREF].

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

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:

  • Send the contents of the buffer that is pointed to by the pBuf parameter to the port.

  • If the value of the cSleep parameter is not zero, the server MUST halt operations to the port for the number of milliseconds specified by the value of the cSleep parameter.

  • Write the number of bytes that were written to the port, to the variable that is pointed to by the pcWritten parameter.

  • Return the status of the operation.