How to Use the StartService API Within a Service

Last reviewed: December 16, 1996
Article ID: Q133756
The information in this article applies to:
  • Microsoft Win32 Application Programming Interface (API) included with:

        - Microsoft Windows NT versions 3.51 and 4.00
    

SUMMARY

In the Win32 API Help file, it mentions that you cannot call the StartService API from within a service. This statement is not totally correct. It should say that you cannot call the StartService API from within a service while it is initializing.

An initializing service is a service which has not yet reported to the Service Control Manager a status of SERVICE_RUNNING. Once the service is running, you can use the StartService API within the service.

MORE INFORMATION

If your service is initializing due to a dependency or the auto start flag, If your service is initializing due to a dependency or the SERVICE_AUTO_START flag, and your service attempts to start another service, a deadlock state in the Service Control Manager may occur. The reason this occurs is because the call to StartService API blocks because the Service Control Manager has a lock on the service control database from the original initializing service.


KBCategory: kbprg kbdocerr
KBSubcategory: BseService
Additional reference words: 3.51 4.00


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: December 16, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.