This function stops a service instance.
A nonzero value indicates success. A value of zero indicates failure. To get extended error information, call GetLastError.
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.
|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.|