HOWTO: How to Gracefully Fail at Service Start |
Q115829
If an error occurs while your service is running or initializing (SERVICE_START_PENDING) and you need to stop the service process, do the following:
Error 2140: An internal Windows NT error occurred
When the last service in the process has terminated (you may have multiple services in the service process), the StartServiceCtrlDispatcher() call in the main thread returns. The main routine should call ExitProcess() because all of the services have terminated.
There is a termination sample in the "Win32 Programmer's Reference," in the "Services" overview section, "Writing a ServiceMain Function." This is a simple situation where the service process only consists of one thread. This thread returns when it is ready to terminate, instead of calling ExitThread().
Additional query words: 3.50
Keywords : kbFileIO kbKernBase kbOSWin2000 kbService kbDSupport kbGrpDSKernBase
Issue type : kbhowto
Technology : kbAudDeveloper kbWin32sSearch kbWin32API
|
Last Reviewed: October 23, 2000 © 2001 Microsoft Corporation. All rights reserved. Terms of Use. |