<div class="content" name="RDeleteService" uuid="6744cdb8-f162-4be0-bb31-98996b6495be"><p>The RDeleteService method marks the specified service for
deletion from 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 RDeleteService(
   [in] SC_RPC_HANDLE hService
 );
</pre></div>
</dd></dl><p><b>hService: </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 the service record 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>. The DELETE
access right MUST have been granted to the caller when the RPC context 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> was
created.</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>5 ERROR_ACCESS_DENIED</td>
  <td>The DELETE access right had not been granted to the caller when the RPC context handle to the service record was created.</td>
 </tr><tr>
  <td>6 ERROR_INVALID_HANDLE</td>
  <td>The handle is no longer valid.</td>
 </tr><tr>
  <td>1072 ERROR_SERVICE_MARKED_FOR_DELETE</td>
  <td>The RDeleteService has already been called for the service record identified by the hService parameter.</td>
 </tr><tr>
  <td>1115 ERROR_SHUTDOWN_IN_PROGRESS</td>
  <td>The system is shutting down.</td>
 </tr></tbody></table>
</dd></dl><p>The server MUST change the Start in the service record to
SERVICE_DISABLED.</p><p>The server MUST set the <b>Deleted</b> field to TRUE in the
service record to indicate that the deletion is pending. </p><p>The server MUST delete the service record when the last RPC
context handle created for the service has been closed by a call to the <span><a href="a2a4e174-09fb-4e55-bad3-f77c4b13245c" data-linktype="relative-path">RCloseServiceHandle</a></span>
(section 3.1.4.1) function.</p></div>