<div class="content"><p> </p><p>The OpenClassesRoot method is called by the client. In
response, the server opens the <b>HKEY_CLASSES_ROOT </b> predefined key.</p><dl>
<dd>
<div><pre> error_status_t OpenClassesRoot(
   [in, unique] PREGISTRY_SERVER_NAME ServerName,
   [in] REGSAM samDesired,
   [out] PRPC_HKEY phKey
 );
</pre></div>
</dd></dl><p><b>ServerName: </b>The server name. The <i>ServerName</i>
SHOULD be sent as NULL, and MUST be ignored when it is received because binding
to the server is already complete at this stage.</p><p><b>samDesired: </b>A bit field that describes the
requested security access for the key. It MUST be constructed from one or more
of the values specified in section <span><a href="fefbc801-b141-4bb1-9dcb-bf366da3ae7e" data-linktype="relative-path">2.2.3</a></span>. </p><p><b>phKey: </b>A pointer to an RPC context handle for
the root key, <b>HKEY_CLASSES_ROOT</b>, as specified in section <span><a href="d93b4170-a865-47bc-a10b-13cb17fbc1b0" data-linktype="relative-path">3.1.1.7</a></span>.
The handle is found in the handle table (<b>HANDLETABLE</b>).</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>Access is denied.</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></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>The server then determines which key namespace to operate on
(KEYS32 or KEYS64) by inspecting the value of the <i>samDesired</i> parameter.</p><p>If server does not support the 64-bit key namespace <span><a href="d962e3a6-30e1-4bb3-9663-cd4751604212" data-linktype="relative-path">3.1.1.4</a></span>,
the server MUST operate on the 32-bit key namespace (KEYS32).</p><p>If the server is a 64-bit registry server and supports both
the 32-bit and 64-bit key namespaces, as defined in section 3.1.1.4, the server
MUST first check if both the KEY_WOW64_64KEY and KEY_WOW64_32KEY bits are set
in the <i>samDesired</i> parameter. If both the KEY_WOW64_64KEY and
KEY_WOW64_32KEY are set, the server SHOULD<a id="Appendix_A_Target_13"></a><a aria-label="Product behavior note 13" href="85f43046-e27d-4122-93ba-bc278f986fbe#Appendix_A_13" data-linktype="relative-path">&lt;13&gt;</a> fail the
method and return ERROR_INVALID_PARAMETER.</p><p>Next, the server checks if the KEY_WOW64_32KEY is set in the
<i>samDesired</i> parameter. If the KEY_WOW64_32KEY is set in the <i>samDesired</i>
parameter, the server MUST open the root key, <b>HKEY_CLASSES_ROOT</b>, in the
32-bit key namespace (KEYS32). If the KEY_WOW64_32KEY is not set in the <i>samDesired</i>
parameter, the server MUST open the root key, <b>HKEY_CLASSES_ROOT</b>, in the
64-bit key namespace (KEYS64). If the root key is to be opened in the 32-bit
key namespace, the server MUST open the root key in the 32-bit key namespace.
The 32-bit key namespace for HKEY_CLASSES_ROOT is stored as a subkey in the
64-bit key namespace in HKEY_CLASSES_ROOT\Wow6432Node.</p><p>The server MUST validate the value of the <i>samDesired</i>
parameter set by the client. If the value of <i>samDesired</i> includes flags
set that are not listed in section 2.2.3, the server MUST return
ERROR_INVALID_PARAMETER.</p><p>The server attempts to open the root key, <b>HKEY_CLASSES_ROOT</b>,
and return a handle to that key in the phKey parameter. The server MUST evaluate
the security descriptor that is associated with the key against the requested
access that is expressed in the samDesired parameter to determine whether the
caller can open this key.</p><p>If the caller is permitted to open the key, the server MUST
return 0 to indicate success and create a new valid context handle. The server
MUST store the context handle value in the handle table (HANDLETABLE) along
with a mapping to the HKEY_CLASSES_ROOT key. The server MUST place the context
handle in the <i>phKey</i> parameter. If the caller does not have access, the
server MUST return ERROR_ACCESS_DENIED (0x00000005). </p></div>