DeregisterService (Windows CE 5.0)

Send Feedback

This function stops a service instance.

BOOL DeregisterService(HANDLEhDevice);

Parameters

Return Values

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 trusted or untrusted applications, regardless of the setting of the DEVFLAGS_TRUSTEDCALLERONLY registry flag for the service. If a trusted application has loaded a service, an untrusted application cannot unload the service. However, if an untrusted application has loaded the service, then either a trusted application or an untrusted application can unload the service.

Requirements

OS Versions: Windows CE .NET 4.0 and later.
Header: Service.h.
Link Library: Coredll.lib.

See Also

ActivateService | RegisterService | GetServiceHandle | xxx_Deinit (Services.exe)| xxx_IOControl (Services.exe) | Services.exe | Services.exe Registry Settings

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.