<div class="content" name="RpcSetPrinterDataEx" uuid="58520b8b-44ce-46fc-90d3-0362457098e0"><p>RpcSetPrinterDataEx sets the configuration data for a
printer or <span><a href="831cd729-be7c-451e-b729-bd8d84ce4d24#gt_59fb3ddc-63cf-45df-8a90-46a6af9e00cb" data-linktype="relative-path">print server</a></span>.<a id="Appendix_A_Target_298"></a><a aria-label="Product behavior note 298" href="e81cbc09-ab05-4a32-ae4a-8ec57b436c43#Appendix_A_298" data-linktype="relative-path">&lt;298&gt;</a> This method is similar to <span><a href="e0d3e41e-097c-459d-a7fb-acaf1343ea27" data-linktype="relative-path">RpcSetPrinterData (section 3.1.4.2.8)</a></span>
but additionally allows the caller to specify the <span><a href="831cd729-be7c-451e-b729-bd8d84ce4d24#gt_2d67ea57-10e6-422f-985e-694834945a02" data-linktype="relative-path">registry</a></span> key under
which to store the data.</p><dl>
<dd>
<div><pre> DWORD RpcSetPrinterDataEx(
   [in] PRINTER_HANDLE hPrinter,
   [in, string] const wchar_t* pKeyName,
   [in, string] const wchar_t* pValueName,
   [in] DWORD Type,
   [in, size_is(cbData)] BYTE* pData,
   [in] DWORD cbData
 );
</pre></div>
</dd></dl><p><b>hPrinter: </b>A handle to a printer object or
server object that was opened by <span><a href="bd0bb8d5-26fd-4705-81f5-614d32b9f38f" data-linktype="relative-path">RpcAddPrinter (section 3.1.4.2.3)</a></span>,
<span><a href="3af45717-308f-4b4f-8428-430d12856110" data-linktype="relative-path">RpcAddPrinterEx (section 3.1.4.2.15)</a></span>,
<span><a href="989357e2-446e-4872-bb38-1dce21e1313f" data-linktype="relative-path">RpcOpenPrinter (section 3.1.4.2.2)</a></span>,
or <span><a href="0e81ce18-72b1-46c3-8584-a205393b04ff" data-linktype="relative-path">RpcOpenPrinterEx (section 3.1.4.2.14)</a></span>.</p><p><b>pKeyName: </b>A pointer to a string that specifies
the key under which the value is to be set. A key name is an arbitrary string
defined by the <span><a href="831cd729-be7c-451e-b729-bd8d84ce4d24#gt_1a48eebd-e72c-494d-b8cb-84dfb7bc3b65" data-linktype="relative-path">printer driver</a></span>
associated with the printer object. For rules governing key names, see section <span><a href="c35aab90-57fc-4099-b388-6ec323ded6ec" data-linktype="relative-path">2.2.4.7</a></span>.</p><dl>
<dd>
<p>If <i>hPrinter</i> is a handle to a server object,
the key name can be NULL, and the server MUST ignore this parameter.</p>
</dd></dl><p><b>pValueName: </b>A pointer to a string that
identifies the data to set. For rules governing value names, see section <span><a href="cd9850cf-1e6c-4875-9b65-e159cf2d83d6" data-linktype="relative-path">2.2.4.18</a></span>.</p><dl>
<dd>
<p>For print servers, a value name is one of the
predefined strings listed in <span><a href="1393a76f-5851-49a5-bf14-7188ca6763b2" data-linktype="relative-path">Server Handle Key
Values (section 2.2.3.10)</a></span>.</p>
</dd>
<dd>
<p>For printer objects, a value name is an arbitrary
string defined by the printer driver associated with the printer object. The
value name &#34;ChangeID&#34; is reserved by the protocol and MUST NOT be
used in a call to RpcSetPrinterDataEx.<a id="Appendix_A_Target_299"></a><a aria-label="Product behavior note 299" href="e81cbc09-ab05-4a32-ae4a-8ec57b436c43#Appendix_A_299" data-linktype="relative-path">&lt;299&gt;</a></p>
</dd></dl><p><b>Type: </b>A code that indicates the type of data
that is pointed to by the <i>pData</i> parameter. The value SHOULD be one of
the possible type codes defined by type values in section <span><a href="25cce700-7fcf-4bb6-a2f3-0f6d08430a55" data-linktype="relative-path">2.2.3.9</a></span>.
For rules governing registry type values, see section <span><a href="f3ded790-0d0a-462b-9bd1-73051033cb8a" data-linktype="relative-path">2.2.4.15</a></span>.</p><p><b>pData: </b>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 <i>Type</i> parameter.</p><p><b>cbData: </b>The size, in bytes, of the <i>pData</i>
array. This value SHOULD NOT be zero.</p><p><b>Return Values: </b>This method MUST return zero
(ERROR_SUCCESS) to indicate successful completion or a nonzero Windows error
code to indicate failure <span><a href="../ms-erref/1bc92ddf-b79e-413c-bbaa-99a5281a6c90" data-linktype="relative-path">[MS-ERREF]</a></span>.</p><p>Upon receiving this message, the server validates parameters
as follows:</p><ul><li><p><span><span> 
</span></span>The server MUST perform the validation steps that are specified
in <span><a href="10bfa8c2-d456-4ad0-912d-e674766a36c8" data-linktype="relative-path">PRINTER_HANDLE
Parameters (section 3.1.4.1.11)</a></span>.</p>
</li><li><p><span><span> 
</span></span>If the <i>hPrinter</i> parameter is a handle to a printer object,
the server MUST verify that the <i>pKeyName</i> parameter points to a string
that complies with the rules for key names specified in section 2.2.4.7.</p>
</li><li><p><span><span> 
</span></span>For server objects, the server MUST verify that the <i>pValueName</i>
parameter points to a string that is one of the predefined value names listed
in Server Handle Key Values (section 2.2.3.10) with the
&#34;read-write&#34; column selected. If this verification fails, return
ERROR_INVALID_PARAMETER.</p>
</li><li><p><span><span> 
</span></span>For printer objects, the server MAY verify that the <i>pValueName</i>
parameter points to a string that complies with the rules specified in section
2.2.4.18.</p>
</li><li><p><span><span> 
</span></span>Additional validation SHOULD<a id="Appendix_A_Target_300"></a><a aria-label="Product behavior note 300" href="e81cbc09-ab05-4a32-ae4a-8ec57b436c43#Appendix_A_300" data-linktype="relative-path">&lt;300&gt;</a> be
performed.</p>
</li></ul><p>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:</p><ul><li><p><span><span> 
</span></span>If the <i>hPrinter</i> parameter is a handle to a printer object,
store the data that is provided by <i>pData</i> with the type that is supplied
by <i>Type</i> in the printer data value that is identified by <i>pKeyName</i>
and <i>pValueName</i>.</p>
</li><li><p><span><span> 
</span></span>If <i>hPrinter</i> is a handle to a server object, store the data
that is provided by <i>pData</i> with the type that is supplied by <i>Type</i>
in the server data value that is identified by the <i>pValueName</i> parameter.</p>
</li><li><p><span><span> 
</span></span>Return the status of the operation.</p>
</li></ul></div>