Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

DeregisterService

Windows Mobile 6.5
A version of this page is also available for
4/8/2010

This function stops a service instance.


BOOL DeregisterService(
  HANDLE hDevice
);
hDevice

[in] Handle to the service instance returned by ActivateService, RegisterService, or GetServiceHandle.

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.

Aa925358.security(en-us,MSDN.10).gifSecurity 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.
Headerservice.h
Librarycoredll.lib
Windows Embedded CEWindows CE .NET 4.0 and later
Windows MobileWindows Mobile Version 5.0 and later
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.