DeregisterService
A version of this page is also available for
4/8/2010
This function stops a service instance.
Syntax
BOOL DeregisterService(
HANDLE hDevice
);
Parameters
- hDevice
[in] Handle to the service instance returned by ActivateService, RegisterService, or GetServiceHandle.
Return Value
A nonzero value indicates success. A value of zero indicates failure. To get extended error information, call GetLastError.
Remarks
DeregisterService will first call into the service's exported xxx_IOControl (Services.exe) with the dwCode value set to IOCTL_SERVICE_QUERY_CAN_DEINIT. If xxx_IOControl returns a value of TRUE and sets the buffer passed in to a nonzero value, DeregisterService will not unload the service. If the service is to be unloaded, all super service sockets associated with the service instance will be unbound and Services.exe will call xxx_Deinit (Services.exe).
If the service instance is the last service loaded by a service DLL, the DLL will be unloaded from memory after the call to xxx_Deinit returns. It is extremely important that no other threads created by the DLL are running after the DLL has been unloaded from memory because unloading the DLL will unload any code pages. Any thread that attempts to access these code pages will cause an exception.
Security Note: |
---|
DeregisterService can be called from either privileged or normal applications, regardless of the setting of the DEVFLAGS_TRUSTEDCALLERONLY registry flag for the service. If a privileged application has loaded a service, a normal application cannot unload the service. However, if a normal application has loaded the service, then either a privileged application or a normal application can unload the service. |
Requirements
Header | service.h |
Library | coredll.lib |
Windows Embedded CE | Windows CE .NET 4.0 and later |
Windows Mobile | Windows Mobile Version 5.0 and later |
See Also
Reference
ActivateService
RegisterService
GetServiceHandle
xxx_Deinit (Services.exe)
xxx_IOControl (Services.exe)
Concepts
Services.exe Registry Settings