3.1.4.2.4 RpcDeletePrinter (Opnum 6)

RpcDeletePrinter is a method that deletes the specified printer object.

 DWORD RpcDeletePrinter(
   [in] PRINTER_HANDLE hPrinter
 );

hPrinter: A handle to a printer object that MUST have been opened by using the RpcAddPrinter, RpcAddPrinterEx, RpcOpenPrinter, or RpcOpenPrinterEx methods.

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 as specified in PRINTER_HANDLE Parameters (section 3.1.4.1.11).

  • If any jobs are pending on the printer, use the implementation-specific policy to determine if a delete operation can be made pending or if an error is returned.<271>

Additional validation MAY be performed. <272>

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:

  • Mark the printer object as "Delete Pending".

  • Modify the list of printers in the system to exclude the deleted printer for any subsequent calls to RpcEnumPrinters, RpcOpenPrinter, RpcOpenPrinterEx, and RpcStartDocPrinter. Clients that already have a valid handle to the same printer object MAY continue using the printer object for all operations except RpcStartDocPrinter.

  • If the deleted printer has been published to the directory service, delete the print queue object from the directory as specified in section 2.3.3.2.<273> If the directory service operation fails, the print server MUST continue processing the printer deletion operation and MUST NOT return the status of the directory service operation to the client.

  • If any clients have registered for notifications of the server object change, a notification MUST be broadcast to them.

  • Return the status of the operation.