This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
Windows Mobile Supported Windows Embedded CE Supported

This function loads a device driver. For additional functionality, use the ActivateDeviceExfunction.


HANDLE ActivateDevice(



[in] Pointer to a string that identifies the location under the HKEY_LOCAL_MACHINEregistry subtree where the Driverregistry subkey for the device resides. A driver registry subkey contains the dynamic-link library (DLL) name, device prefix, friendly name, and other device information.


[in] Data to store in the Activeregistry subkey for the device in the ClientInforegistry entry.

For Windows Embedded CE:

The registry path to the Activeregistry subkey for the device is passed in as the contextparameter to the device's XXX_Init (Device Manager)function. After the value in dwClientInfois stored in the registry under HKEY_LOCAL_MACHINE\Drivers\Active, the Device Manager calls XXX _Init. Devload.h defines DEVLOAD_CLIENTINFO_VALNAME and DEVLOAD_CLIENTINFO_VALTYPE to facilitate access to the ClientInfokey.

Return Value

Returns a handle to the device that you can use in subsequent calls to the DeactivateDevicefunction, if successful. If the function is not successful, it returns NULL. To obtain extended error information, call GetLastError.


ActivateDeviceloads a device driver and reads the registry key specified in lpszDevKeyto get the DLL name, device prefix, index, and other values. Next, it adds the device to the active device list in the HKEY_LOCAL_MACHINE\Drivers\Activeregistry key, and stores the relevant values there. If you do not specify a device index in the registry subkey specified in lpszDevKey, then ActivateDeviceassigns a free index. Then, ActivateDeviceloads the device driver DLL in the process space of the Device Manager. Finally, the Device Manager sends a device notification message for the new device. For more information on device notifications, see Device Interface Notifications.

If the entire OS must recognize the driver, and your applications must load custom-purpose device drivers, use ActivateDevice.


Header winbase.h
Library coredll.lib
Windows Embedded CE Windows CE 2.11 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also