<div class="content" name="RCloseServiceHandle" uuid="a2a4e174-09fb-4e55-bad3-f77c4b13245c"><p>The RCloseServiceHandle method is called by the client. In
response, the server releases the handle to the specified <span><a href="4f66d32e-2f4f-4482-998e-e5ccbb445223#gt_2dc07ca2-2b40-437e-a5ec-ed28ebfb116a" data-linktype="relative-path">service</a></span>
or the <span><a href="4f66d32e-2f4f-4482-998e-e5ccbb445223#gt_afc3f782-a908-486d-9c05-8a054cd9cc84" data-linktype="relative-path">SCM</a></span> database.</p><dl>
<dd>
<div><pre> DWORD RCloseServiceHandle(
   [in, out] LPSC_RPC_HANDLE hSCObject
 );
</pre></div>
</dd></dl><p><b>hSCObject: </b>An <span><a href="b5f0a0a8-887c-4097-af1c-71ef9f214ce4" data-linktype="relative-path">SC_RPC_HANDLE</a></span>
(section 2.2.4) data type that defines the handle to a service record or to the
SCM database that MUST have been created previously using one of the open
methods specified in section <span><a href="0d7a7011-9f41-470d-ad52-8535b47ac282" data-linktype="relative-path">3.1.4</a></span>.</p><p><b>Return Values: </b>The method returns 0x00000000
(ERROR_SUCCESS) on success; otherwise, it returns the following error code.</p><dl>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Return value/code</p>
   </th>
   <th>
   <p>Description</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>6 ERROR_INVALID_HANDLE</td>
  <td>The handle is no longer valid.</td>
 </tr><tr>
  <td>0xFFFF75FD</td>
  <td>The operation completed successfully. Additionally, the passed handle was the last one created for the associated service record that was previously used in a successful call to the RNotifyServiceStatusChange (section 3.1.4.43) method.</td>
 </tr><tr>
  <td>0xFFFF75FE</td>
  <td>The operation completed successfully. Additionally, the passed handle was previously used in a successful call to the RNotifyServiceStatusChange method.</td>
 </tr></tbody></table>
</dd></dl><p>In response to this request from the client, for a
successful operation, the server MUST close the handle to the <span><a href="4f66d32e-2f4f-4482-998e-e5ccbb445223#gt_1fbb7936-8437-4e3d-b62f-47df3be07721" data-linktype="relative-path">service
record</a></span> or the SCM database specified by the <i>hSCObject</i>
parameter specified in the client request.</p><p>If <i>hSCObject</i> is the RPC control handle that has been
created for the service record, the server MUST decrement the <b>HandleCount</b>
field of the service record. If the <b>Deleted</b> field of the service record
indicates that <span><a href="6744cdb8-f162-4be0-bb31-98996b6495be" data-linktype="relative-path">RDeleteService</a></span> has
been successfully called with the RPC control handle created for the same
service record, and <b>HandleCount</b> indicates that <i>hSCObject</i> is the
last RPC control handle created for this service record, the server MUST delete
the service record. </p></div>