A Win32-based service calls the RegisterServiceCtrlHandler function to register a function to handle its service control requests.
SERVICE_STATUS_HANDLE RegisterServiceCtrlHandler(
LPCTSTR lpServiceName, |
// address of name of service |
LPHANDLER_FUNCTION lpHandlerProc |
// address of handler function |
); |
If the function succeeds, the return value is a service status handle.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
The following error codes can be set by the service control manager. Other error codes can be set by the registry functions that are called by the service control manager.
Value |
Meaning |
ERROR_INVALID_NAME |
The specified service name is invalid. |
ERROR_SERVICE_DOES_NOT_EXIST |
The specified service does not exist. |
The ServiceMain function of a new service should immediately call the RegisterServiceCtrlHandler function to register a control handler function with the control dispatcher. This enables the control dispatcher to invoke the specified function when it receives control requests for this service. The threads of the calling process can use the service status handle returned by this function to identify the service in subsequent calls to the SetServiceStatus function.
This function must be called before the first SetServiceStatus call because it returns a service status handle for the caller to use so that no other service can inadvertently set this service status. In addition, the control handler must be in place to field control requests by the time the service specifies the controls it accepts through the SetServiceStatus function.
When the control handler function is invoked with a control request, it must call SetServiceStatus to notify the service control manager of its current status, regardless of whether the status of the service has changed.
The service status handle does not have to be closed.
CreateService, Handler, ServiceMain, SetServiceStatus
file: /Techref/os/win/api/win32/func/src/f72_18.htm, 4KB, , updated: 2000/4/7 12:19, local time: 2024/10/3 03:51,
35.171.164.77:LOG IN ©2024 PLEASE DON'T RIP! THIS SITE CLOSES OCT 28, 2024 SO LONG AND THANKS FOR ALL THE FISH!
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://massmind.org/techref/os/win/api/win32/func/src/f72_18.htm"> RegisterServiceCtrlHandler</A> |
Did you find what you needed? |
Welcome to massmind.org! |
Welcome to massmind.org! |
.