共用方式為


3.1.4.2.8 RpcSetPrinterData (Opnum 27)

RpcSetPrinterData sets the configuration data for a printer or print server.

 DWORD RpcSetPrinterData(
   [in] PRINTER_HANDLE hPrinter,
   [in, string] wchar_t* pValueName,
   [in] DWORD Type,
   [in, size_is(cbData)] BYTE* pData,
   [in] DWORD cbData
 );

hPrinter: A handle to a printer object or server object that was opened by RpcAddPrinter (section 3.1.4.2.3), RpcAddPrinterEx (section 3.1.4.2.15), RpcOpenPrinter (section 3.1.4.2.2), or RpcOpenPrinterEx (section 3.1.4.2.14).

pValueName: A pointer to a string that identifies the configuration data to set. For rules governing value names, see section 2.2.4.18.

For print servers, the value name is one of the predefined strings listed in Server Handle Key Values (section 2.2.3.10).

For printer objects, the value name is an arbitrary string defined by the printer driver associated with the printer object. The value name "ChangeID"<281> is reserved by the protocol and MUST NOT be used in a call to RpcSetPrinterData.

Type: The type value for data pointed to by the pData parameter. This value SHOULD be one of the type codes defined in section 2.2.3.9. For rules governing registry type values, see section 2.2.4.15.

pData: A pointer to an array of bytes that contain the printer configuration data. The type of the data in the buffer is specified by the Type parameter.

cbData: The size, in bytes, of the pData array. This value SHOULD NOT be zero.

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 validates parameters as follows:

  • The server MUST perform the validation steps that are specified in PRINTER_HANDLE Parameters (section 3.1.4.1.11),.

  • For server objects, the server MUST verify that the pValueName parameter points to a string that is one of the predefined value names listed in Server Handle Key Values with the "read-write" column selected. If this verification fails, return ERROR_INVALID_PARAMETER.

  • For printer objects, the server MAY verify that the pValueName parameter points to a string that complies with the rules specified in section 2.2.4.18.

  • Additional validation SHOULD<282> 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:

  • Set the printer data associated with pValueName to the data pointed to by pData.<283>

  • Return the status of the operation.