<div class="content"><p>The RLockServiceDatabase method acquires a lock on an <a href="4f66d32e-2f4f-4482-998e-e5ccbb445223#gt_afc3f782-a908-486d-9c05-8a054cd9cc84" data-linktype="relative-path">SCM</a> database.</p><dl>
<dd>
<div><pre> DWORD RLockServiceDatabase(
   [in] SC_RPC_HANDLE hSCManager,
   [out] LPSC_RPC_LOCK lpLock
 );
</pre></div>
</dd></dl><p><b>hSCManager: </b>An <a href="b5f0a0a8-887c-4097-af1c-71ef9f214ce4" data-linktype="relative-path">SC_RPC_HANDLE (section 2.2.4)</a>
data type that defines the handle to the SCM database created using one of the
open methods specified in section <a href="0d7a7011-9f41-470d-ad52-8535b47ac282" data-linktype="relative-path">3.1.4</a>. The caller MUST be
granted the SC_MANAGER_LOCK access right when the RPC context handle is
created.</p><p><b>lpLock: </b>An <a href="69737921-6d31-4731-b3f8-56f3bc510e5a" data-linktype="relative-path">LPSC_RPC_LOCK (section 2.2.5)</a>
data type that defines the handle to the resulting database lock.</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_LOCK access rights had not been granted
  to the caller when the RPC context handle was created.</p>
  </td>
 </tr><tr>
  <td>
  <p>6</p>
  <p>ERROR_INVALID_HANDLE</p>
  </td>
  <td>
  <p>The handle is no longer valid.</p>
  </td>
 </tr><tr>
  <td>
  <p>1055</p>
  <p>ERROR_SERVICE_DATABASE_LOCKED</p>
  </td>
  <td>
  <p>The service database is locked.</p>
  </td>
 </tr></tbody></table>
</dd></dl><p>In response to this request from the client, for a
successful operation, the server SHOULD lock the SCM database identified by the
<i>hSCManager</i> parameter of the client request.<a id="Appendix_A_Target_36"></a><a aria-label="Product behavior note 36" href="041d2a89-9d7d-4f79-91a1-c336d0a668f6#Appendix_A_36" data-linktype="relative-path">&lt;36&gt;</a></p><p>After the database is locked, the server MUST respond with
error code ERROR_SERVICE_DATABASE_LOCKED (1055) for future
RLockServiceDatabase, <a href="d9be95a2-cf01-4bdc-b30f-6fe4b37ada16" data-linktype="relative-path">RStartServiceW</a>,
and <a href="f15fc391-8576-4e30-b158-75c306e1cba2" data-linktype="relative-path">RStartServiceA</a> <a href="4f66d32e-2f4f-4482-998e-e5ccbb445223#gt_8a7f6700-8311-45bc-af10-82e10accd331" data-linktype="relative-path">RPCs</a>. All other methods are
unaffected.<a id="Appendix_A_Target_37"></a><a aria-label="Product behavior note 37" href="041d2a89-9d7d-4f79-91a1-c336d0a668f6#Appendix_A_37" data-linktype="relative-path">&lt;37&gt;</a></p><p>If the client holding the lock crashes or does not cleanly
shut down, then an RPC context handle rundown callback executes on the server
to release the lock. See <a href="../ms-rpce/290c38b1-92fe-4229-91e6-4fc376610c15" data-linktype="relative-path">[MS-RPCE]</a>
section <a href="../ms-rpce/678e4235-0a3b-4b81-99fb-86ae3ac357f3" data-linktype="relative-path">3.3.3.2.1</a>
Connection Time-out.</p></div>