ActivateDevice

This function loads a device driver in the manner that the plug and play system loads a device driver.

At a Glance

Header file: Winbase.h
Windows CE versions: 2.11 and later

Syntax

HANDLE ActivateDevice(LPCWSTR lpszDevKey, DWORD dwClientInfo);

Paramters

lpszDevKey

Pointer to the registry path string of the device's driver key under HKEY_LOCAL_MACHINE. A driver key contains the DLL name, the device prefix, friendly name, and other device information.

dwClientInfo

Specifies per instance information that is stored in the Active key of the newly loaded device in the entry named ClientInfo.

Return Values

A handle to the device indicates success. Zero indicates failure.

Remarks

ActivateDevice uses the RegisterDevice function to load the device driver, then it adds the device to the active device list under HKEY_LOCAL_MACHINE\Drivers\Active key, then it sends a ii message for the new device and triggers a NOTIFICATION_EVENT_DEVICE_CHANGE event in the application notification system to notify applications system-wide of the presence of the new device.

ActivateDevice returns a handle to the device that can be used in a subsequent call to the DeactivateDevice function, which unloads the device driver, deletes the device's active key, sends a WM_DEVICECHANGE message, and triggers a NOTIFICATION_EVENT_DEVICE_CHANGE.

The registry path to the device's active key is passed in as the context parameter to the device's XXX_Init function. The dwClientInfo value is not stored in the registry before XXX_Init is called.