<div class="content"><p> </p><p>The BaseRegQueryValue method is called by the client. In
response, the server returns the data that is associated with the named value
of a specified registry open key. If a value name is not specified, the server
returns the data that is associated with the default value of the specified <span><a href="261b039d-95d9-4749-9680-db1851d03945#gt_2d67ea57-10e6-422f-985e-694834945a02" data-linktype="relative-path">registry</a></span>
open key.</p><dl>
<dd>
<div><pre> error_status_t BaseRegQueryValue(
   [in] RPC_HKEY hKey,
   [in] PRRP_UNICODE_STRING lpValueName,
   [in, out, unique] LPDWORD lpType,
   [in, out, unique, size_is(lpcbData ? *lpcbData :0), length_is(lpcbLen ? *lpcbLen : 0), range(0, 0x4000000)] 
     LPBYTE lpData,
   [in, out, unique] LPDWORD lpcbData,
   [in, out, unique] LPDWORD lpcbLen
 );
</pre></div>
</dd></dl><p><b>hKey: </b>On input, a handle to a key that MUST
have been opened previously by using one of the open methods that are specified
in section <span><a href="053e8515-dbae-47ea-a7c6-6dc054e3a48f" data-linktype="relative-path">3.1.5</a></span>: <span><a href="956a3052-6580-43ee-91aa-aaf61726149b" data-linktype="relative-path">OpenClassesRoot</a></span>,
<span><a href="ec140ed9-4d00-4c03-a15c-c7245a497ed5" data-linktype="relative-path">OpenCurrentUser</a></span>,
<span><a href="6cef29ae-21ba-423f-9158-05145ac80a5b" data-linktype="relative-path">OpenLocalMachine</a></span>,
<span><a href="7b514c63-6cad-4fe1-9780-743959e377e6" data-linktype="relative-path">OpenPerformanceData</a></span>,
<span><a href="694e57f4-da3e-4285-8b71-3181d71d6cd1" data-linktype="relative-path">OpenUsers</a></span>,
<span><a href="c7186ae2-1c82-45e9-933b-97d9873657e8" data-linktype="relative-path">BaseRegCreateKey</a></span>,
<span><a href="8cb48f55-19e1-4ea2-8d76-dd0f6934f0d9" data-linktype="relative-path">BaseRegOpenKey</a></span>,
<span><a href="160767d7-83cf-4718-a4f3-d864faee3bb1" data-linktype="relative-path">OpenCurrentConfig</a></span>,
<span><a href="44954f6d-ef2c-4ec1-a27d-32b9b87e3c8a" data-linktype="relative-path">OpenPerformanceText</a></span>,
<span><a href="3626fa8a-b20f-4243-bf85-cdb615ed2ca0" data-linktype="relative-path">OpenPerformanceNlsText</a></span>.</p><p><b>lpValueName: </b>On input, the client sets <i>lpValueName</i>
to a pointer to an <span><a href="c0c90f11-a4c4-496a-ac09-8a8a3697ceef" data-linktype="relative-path">RRP_UNICODE_STRING</a></span>
structure that MUST contain the name of the value, as specified in section <span><a href="508e3d3e-1225-4075-be04-67680ea80497" data-linktype="relative-path">3.1.1</a></span>.
If the client sets <i>lpValueName</i> to NULL, the server MUST fail this method
and return ERROR_INVALID_PARAMETER.</p><p><b>lpType: </b>On input, the client sets <i>lpType</i>
to a pointer to a variable to receive the type code of a <span><a href="261b039d-95d9-4749-9680-db1851d03945#gt_7bc13a0c-ca1a-4c78-b1bf-67e243f778bb" data-linktype="relative-path">value</a></span>
entry. On output, the server MUST set this parameter to NULL if the value
specified by the <i>lpValueName</i> parameter is not found. If the client sets <i>lpType</i>
to NULL, the server MUST fail this method and return ERROR_INVALID_PARAMETER.</p><p><b>lpData: </b>On input, the client sets <i>lpData</i>
to a pointer to a buffer to receive the data of the value entry.</p><p><b>lpcbData: </b>A pointer to a variable that, on
input, contains the size in bytes of the buffer that is pointed to by the <i>lpData</i>
parameter. On output, the variable receives the number of bytes that are
returned in <i>lpData</i>. This length variable MUST be set to 0 by the server
if the client provides NULL for the <i>lpData</i> parameter.</p><dl>
<dd>
<p>If the client sets <i>lpcbData</i> to NULL, the
server MUST fail this method and return ERROR_INVALID_PARAMETER.</p>
</dd></dl><p><b>lpcbLen: </b>A pointer to a variable that contains
the number of bytes to transmit to the client. On input, the client MUST
allocate the memory for this parameter and the pointer value of this parameter
MUST not be NULL. On output, the server MUST set this parameter to the size (in
bytes) of the buffer pointed to by the <i>lpData</i> parameter. If the client
sets <i>lpcbLen</i> to NULL, the server MUST fail this method and return
ERROR_INVALID_PARAMETER.</p><p><b>Return Values: </b>The method returns 0
(ERROR_SUCCESS) to indicate success; otherwise, it returns a nonzero error
code, as specified in <span><a href="../ms-erref/1bc92ddf-b79e-413c-bbaa-99a5281a6c90" data-linktype="relative-path">[MS-ERREF]</a></span>
section <span><a href="../ms-erref/18d8fbe8-a967-4f1c-ae50-99ca8e491d2d" data-linktype="relative-path">2.2</a></span>.
The most common error codes are listed in the following table.</p><dl>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Return value/code</p>
   </th>
   <th>
   <p>Description</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>
  <p>0x00000005</p>
  <p>ERROR_ACCESS_DENIED</p>
  </td>
  <td>
  <p>The caller does not have KEY_QUERY_VALUE access
  rights.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x00000057</p>
  <p>ERROR_INVALID_PARAMETER</p>
  </td>
  <td>
  <p>A parameter is incorrect. </p>
  </td>
 </tr><tr>
  <td>
  <p>0x00000002</p>
  <p>ERROR_FILE_NOT_FOUND</p>
  </td>
  <td>
  <p>The value specified by <i>lpValueName</i> was not
  found. If <i>lpValueName</i> was not specified, the default value has not
  been defined.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x00000013</p>
  <p>ERROR_WRITE_PROTECT</p>
  </td>
  <td>
  <p>A read or write operation was attempted to a volume
  after it was dismounted. The server can no longer service registry requests
  because server shutdown has been initiated.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x000000EA</p>
  <p>ERROR_MORE_DATA</p>
  </td>
  <td>
  <p>The data to be returned is larger than the buffer
  provided.</p>
  </td>
 </tr></tbody></table>
</dd></dl><p>Server Operations</p><p>If the registry server can no longer service registry requests
because server shutdown has been initiated (<b>SHUTDOWNINPROGRESS</b> is set to
TRUE), the server MUST return ERROR_WRITE_PROTECT.</p><p>In response to this request from the client, for a
successful operation, the server MUST return the data that is associated with
the value that is specified by the <i>lpValueName</i> parameter for the key
that is specified by the <i>hKey</i> parameter.</p><p>If, on input, the <i>lpValueName</i> parameter in the client
request is an empty string, the server MUST return the data that is associated
with the default value, as specified in section <span><a href="3d64dbea-f016-4373-8cac-e43bf343837d" data-linktype="relative-path">3.1.1.5</a></span>.</p><p>The server MUST return, on output, a pointer to a variable
to specify the value type in the <i>lpType</i> parameter. The value of <i>lpType</i>
MUST be one of the values that is specified by <span><a href="261b039d-95d9-4749-9680-db1851d03945#gt_71bc18b6-b775-4d09-9a24-949ff7420e2a" data-linktype="relative-path">REG_VALUE_TYPES</a></span> (as
specified in section 3.1.1.5), or it MUST be NULL.</p><p>If the client sets the <i>lpValueName</i> parameter to NULL,
the server MUST fail the method and return ERROR_INVALID_PARAMETER.</p><p>If the client sets the <i>lpData</i> parameter to NULL on
input, the server assumes the client request is to determine the actual size of
the data contained in the value indicated by <i>lpValueName</i>, such that an
adequate-sized buffer can be provided by the client in a subsequent call to
BaseRegQueryValue. If the client sets the <i>lpData</i> parameter to NULL on
input, the server MUST return ERROR_SUCCESS and return the actual size of the
data of the value indicated by <i>lpValueName</i> in the <i>lpcbData</i>
parameter.</p><p>The server MUST return, on output, the data that is
associated with the specified value in the buffer that is pointed to by the <i>lpData</i>
parameter. If the size, in bytes, of the data that is associated with the
specified value is too large to fit in the buffer pointed to by the <i>lpData</i>
parameter with size specified by the <i>lpcbData</i> parameter, the server MUST
return ERROR_MORE_DATA. The server MUST, on output, update the value of the
variable pointed to by the <i>lpcbData</i> parameter to the actual size of the
data associated with the specified value. This enables the client to determine
the correct size of the <i>lpData</i> parameter in a subsequent call to
BaseRegQueryValue.</p><p>The server, on output, MUST return (in the value that is
pointed to by the <i>lpcbData</i> parameter) the size in bytes of the data that
is returned in the <i>lpData</i> parameter. If the <i>lpData</i> parameter is
NULL, the server SHOULD<a id="Appendix_A_Target_21"></a><a aria-label="Product behavior note 21" href="85f43046-e27d-4122-93ba-bc278f986fbe#Appendix_A_21" data-linktype="relative-path">&lt;21&gt;</a> set the
value of the <i>lpcbData</i> parameter to NULL. </p><p>If the server operation is not successful, the server MUST
set the value of the variable pointed to by <i>lpcbLen</i> to 0.</p><p>The caller MUST have KEY_QUERY_VALUE access rights to invoke
this method. For more information, see section <span><a href="fefbc801-b141-4bb1-9dcb-bf366da3ae7e" data-linktype="relative-path">2.2.4</a></span>.</p><p>If the caller does not have access, the server MUST return
ERROR_ACCESS_DENIED.</p></div>