<div class="content" name="RNotifyServiceStatusChange" uuid="b4cb2447-1f8c-4dee-a78e-209bdacadea6"><p>The RNotifyServiceStatusChange method<a id="Appendix_A_Target_74"></a><a aria-label="Product behavior note 74" href="041d2a89-9d7d-4f79-91a1-c336d0a668f6#Appendix_A_74" data-linktype="relative-path">&lt;74&gt;</a> allows the client to register
for notifications and check, via <span><a href="7020f3e1-17b9-4956-80dc-583ea1509fe6" data-linktype="relative-path">RGetNotifyResults (section 3.1.4.44)</a></span>,
when the specified service of type SERVICE_WIN32_OWN_PROCESS or
SERVICE_WIN32_SHARE_PROCESS is created or deleted or when its status changes.</p><dl>
<dd>
<div><pre> DWORD RNotifyServiceStatusChange(
   [in] SC_RPC_HANDLE hService,
   [in] SC_RPC_NOTIFY_PARAMS NotifyParams,
   [in] GUID* pClientProcessGuid,
   [out] GUID* pSCMProcessGuid,
   [out] PBOOL pfCreateRemoteQueue,
   [out] LPSC_NOTIFY_RPC_HANDLE phNotify
 );
</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> data
type that defines the handle to the SCM for SERVICE_NOTIFY_CREATED and
SERVICE_NOTIFY_DELETED notifications or to the <span><a href="4f66d32e-2f4f-4482-998e-e5ccbb445223#gt_1fbb7936-8437-4e3d-b62f-47df3be07721" data-linktype="relative-path">service record</a></span> for
all other notification types 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
SC_MANAGER_ENUMERATE_SERVICE access right MUST have been granted to the caller
when the <span><a href="4f66d32e-2f4f-4482-998e-e5ccbb445223#gt_9dfe84e3-a772-4ad1-9a25-1255c1dc0f84" data-linktype="relative-path">RPC context handle</a></span>
to the <span><a href="4f66d32e-2f4f-4482-998e-e5ccbb445223#gt_afc3f782-a908-486d-9c05-8a054cd9cc84" data-linktype="relative-path">SCM</a></span> was created, or
the SERVICE_QUERY_STATUS access right MUST have been granted to the caller when
the RPC context handle to the service record was created.</p><p><b>NotifyParams: </b>An <span><a href="0e88b912-da92-411d-915a-b9b7df6d64fc" data-linktype="relative-path">SC_RPC_NOTIFY_PARAMS</a></span>
(section 2.2.23) data type that defines the service status notification
information.</p><p><b>pClientProcessGuid: </b>Not used. This MUST be
ignored.</p><p><b>pSCMProcessGuid: </b>Not used. This MUST be
ignored.</p><p><b>pfCreateRemoteQueue: </b>Not used. This MUST be
ignored.</p><p><b>phNotify: </b>An <span><a href="40e0fec2-d70a-4182-9a45-b5da7e2d0943" data-linktype="relative-path">LPSC_NOTIFY_RPC_HANDLE</a></span>
(section 2.2.6) data type that defines a handle to the notification status
associated with the client for the specified service.</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 SC_MANAGER_ENUMERATE_SERVICE access right had not been granted to the caller when the RPC context handle to the SCM was created, or the SERVICE_QUERY_STATUS 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 or is not supported for the specified notification.</td>
 </tr><tr>
  <td>50 ERROR_NOT_SUPPORTED</td>
  <td>The request is not supported.</td>
 </tr><tr>
  <td>87 ERROR_INVALID_PARAMETER</td>
  <td>A parameter that was specified is invalid.</td>
 </tr><tr>
  <td>124 ERROR_INVALID_LEVEL</td>
  <td>The system call level is not correct.</td>
 </tr><tr>
  <td>1072 ERROR_SERVICE_MARKED_FOR_DELETE</td>
  <td>The RDeleteService has 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><tr>
  <td>1242 ERROR_ALREADY_REGISTERED</td>
  <td>A notification status handle has already been created for the service handle passed in the hService parameter.</td>
 </tr><tr>
  <td>1294 ERROR_SERVICE_NOTIFY_CLIENT_LAGGING</td>
  <td>The service notification client is lagging too far behind the current state of services in the machine.</td>
 </tr></tbody></table>
</dd></dl><p>In response to this request from the client, for a
successful operation, the server MUST associate NOTIFY_RPC_HANDLE for the
caller to check for status changes using RGetNotifyResults for the service
record identified by the <i>hService</i> parameter.</p><p>The server MUST ignore any value set in the <i>ullThreadId</i>
parameter in <i>NotifyParams</i>.</p><p>The server MUST fail the call and return
ERROR_INVALID_PARAMETER if <i>dwNotifyMask</i> contains masks for both
create/delete events and service status events.</p><p>The client can set the value of <i>pClientProcessGuid</i>, <i>pSCMProcessGuid</i>,
and <i>pfCreatRemoteQueue</i> to any value, such as 0, and the server MUST
ignore these.</p><p>The server MUST return ERROR_NOT_SUPPORTED (50) if the value
of <i>dwInfoLevel</i> is greater than SERVICE_NOTIFY_STATUS_CHANGE.</p><p>The server MUST return ERROR_INVALID_LEVEL (124) if the
value of <i>dwInfoLevel</i> is not SERVICE_NOTIFY_STATUS_CHANGE (0x2) or
SERVICE_NOTIFY_STATUS_CHANGE_1 (0x1).</p></div>