<div class="content"><p>The ROpenSCManagerA method opens a connection to the <a href="4f66d32e-2f4f-4482-998e-e5ccbb445223#gt_afc3f782-a908-486d-9c05-8a054cd9cc84" data-linktype="relative-path">SCM</a> from the client and
then opens the specified SCM database.</p><dl>
<dd>
<div><pre> DWORD ROpenSCManagerA(
   [in, string, unique, range(0, SC_MAX_COMPUTER_NAME_LENGTH)] 
     SVCCTL_HANDLEA lpMachineName,
   [in, string, unique, range(0, SC_MAX_NAME_LENGTH)] 
     LPSTR lpDatabaseName,
   [in] DWORD dwDesiredAccess,
   [out] LPSC_RPC_HANDLE lpScHandle
 );
</pre></div>
</dd></dl><p><b>lpMachineName: </b>An <a href="7e6a73a5-f795-4cee-a230-cf4056eef4d6" data-linktype="relative-path">SVCCTL_HANDLEA (section 2.2.2)</a>
data type that defines the pointer to a null-terminated ANSI string that
specifies the server&#39;s machine name.</p><p><b>lpDatabaseName: </b>A pointer to a null-terminated
ANSI 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 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 (section 2.2.4)</a>
data type that defines the handle to the newly opened SCM connection.</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 SC_MANAGER_CONNECT access right or the desired
  access is not granted to the caller 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 after evaluating the client security context against the 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_45"></a><a aria-label="Product behavior note 45" href="041d2a89-9d7d-4f79-91a1-c336d0a668f6#Appendix_A_45" data-linktype="relative-path">&lt;45&gt;</a></p><p>The server MUST use the process described in <a href="f9ddeebe-b05e-423c-9440-84fd3d14bee9" data-linktype="relative-path">Conversion Between ANSI and
Unicode String Formats (section 3.1.7)</a> to convert a string to the
appropriate format.</p><p>The server MUST return ERROR_INVALID_NAME (123) if <i>lpDatabaseName</i>
is not NULL and is not ServicesActive or ServicesFailed.</p><p>The server MUST return ERROR_DATABASE_DOES_NOT_EXIST (1065)
if <i>lpDatabaseName</i> is ServicesFailed.</p></div>