<div class="content"><p>The ROpenSCManager2 method establishes a connection to
server and opens the <a href="4f66d32e-2f4f-4482-998e-e5ccbb445223#gt_afc3f782-a908-486d-9c05-8a054cd9cc84" data-linktype="relative-path">SCM</a>
database on the specified server.<a id="Appendix_A_Target_87"></a><a aria-label="Product behavior note 87" href="041d2a89-9d7d-4f79-91a1-c336d0a668f6#Appendix_A_87" data-linktype="relative-path">&lt;87&gt;</a></p><dl>
<dd>
<div><pre> DWORD ROpenSCManager2(
   [in] handle_t hBindingHandle,
   [in, string, unique, range(0, SC_MAX_NAME_LENGTH)] 
     wchar_t* lpDatabaseName,
   [in] DWORD dwDesiredAccess,
   [out] LPSC_RPC_HANDLE lpScHandle
 );
</pre></div>
</dd></dl><p><b>hBindingHandle: </b>An RPC binding handle, as
specified in <a href="../ms-dtyp/cca27429-5689-4a16-b2b4-9325d93e4ba2" data-linktype="relative-path">[MS-DTYP]</a>
section <a href="../ms-dtyp/03c032cd-c1d1-4bbe-b00c-bb1f8da5155b" data-linktype="relative-path">2.1.3</a>,
representing the information needed to establish a relationship with a specific
server.</p><p><b>lpDatabaseName: </b>A pointer to a null-terminated
<a href="4f66d32e-2f4f-4482-998e-e5ccbb445223#gt_c305d0ab-8b94-461a-bd76-13b40cb8c4d8" data-linktype="relative-path">Unicode</a> string that
specifies the name of the SCM database to open. The parameter MUST be set to
NULL, &#34;ServicesActive&#34;, or &#34;ServicesFailed&#34;.</p><p><b>dwDesiredAccess: </b>A value that specifies the
access to the database. This MUST be one of the values as specified in section <a href="0d7a7011-9f41-470d-ad52-8535b47ac282" data-linktype="relative-path">3.1.4</a>.</p><dl>
<dd>
<p>The client MUST also have the SC_MANAGER_CONNECT
access right.</p>
</dd></dl><p><b>lpScHandle: </b>An <a href="b5f0a0a8-887c-4097-af1c-71ef9f214ce4" data-linktype="relative-path">LPSC_RPC_HANDLE</a> (section
2.2.4) data type that defines the handle to the newly opened SCM database.</p><p><b>Return Values: </b>The method returns 0x00000000
(ERROR_SUCCESS) on success; otherwise, it returns one of the following error
codes.</p><dl>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Return value/code</p>
   </th>
   <th>
   <p>Description</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>
  <p>5</p>
  <p>ERROR_ACCESS_DENIED</p>
  </td>
  <td>
  <p>The client does not have the required access rights to
  open the SCM database on the server or the desired access is not granted to
  it in the SCM SecurityDescriptor.</p>
  </td>
 </tr><tr>
  <td>
  <p>123</p>
  <p>ERROR_INVALID_NAME</p>
  </td>
  <td>
  <p>The specified service name is invalid.</p>
  </td>
 </tr><tr>
  <td>
  <p>1065</p>
  <p>ERROR_DATABASE_DOES_NOT_EXIST</p>
  </td>
  <td>
  <p>The database specified does not exist.</p>
  </td>
 </tr><tr>
  <td>
  <p>1115</p>
  <p>ERROR_SHUTDOWN_IN_PROGRESS</p>
  </td>
  <td>
  <p>The system is shutting down.</p>
  </td>
 </tr></tbody></table>
</dd></dl><p>In response to this request from the client, for a
successful operation the server MUST create an RPC context handle to the SCM
database and grant subsequent access specified in the <i>dwDesiredAccess</i>
parameter of the client request to clients using this handle after evaluating
the client security context against SCM SecurityDescriptor. The server MUST
return this handle by setting the <i>lpScHandle</i> parameter of the client
request.</p><p>If the caller cannot be granted permission requested in the <i>dwDesiredAccess</i>
parameter, the server MUST fail the call.<a id="Appendix_A_Target_88"></a><a aria-label="Product behavior note 88" href="041d2a89-9d7d-4f79-91a1-c336d0a668f6#Appendix_A_88" data-linktype="relative-path">&lt;88&gt;</a></p><p>The server MUST return ERROR_INVALID_NAME (123) if <i>lpDatabaseName</i>
is not NULL and not ServicesActive or ServicesFailed.</p><p>The server MUST return ERROR_DATABASE_DOES_NOT_EXIST (1065)
if <i>lpDatabaseName</i> is ServicesFailed.</p></div>