<div class="content"><p>The ROpenSCManagerW 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.</p><dl>
<dd>
<div><pre> DWORD ROpenSCManagerW(
   [in, string, unique, range(0, SC_MAX_COMPUTER_NAME_LENGTH)] 
     SVCCTL_HANDLEW lpMachineName,
   [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>lpMachineName: </b>An <a href="807438c1-bff9-40b8-9216-98e8136ed4d4" data-linktype="relative-path">SVCCTL_HANDLEW</a> (section
2.2.3) data type that defines the pointer to a null-terminated <b>UNICODE</b>
string that specifies the server&#39;s machine name.</p><p><b>lpDatabaseName: </b>A pointer to a null-terminated
<b>UNICODE</b> 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> 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_40"></a><a aria-label="Product behavior note 40" href="041d2a89-9d7d-4f79-91a1-c336d0a668f6#Appendix_A_40" data-linktype="relative-path">&lt;40&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>