ActivateDevice

Other versions of this page are also available for the following:

Windows Mobile SupportedWindows Embedded CE Supported

8/28/2008

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

Syntax

HANDLE ActivateDevice(
  LPCWSTR lpszDevKey, 
  DWORD dwClientInfo
);

Parameters

  • lpszDevKey
    [in] Pointer to a string that identifies the location under the HKEY_LOCAL_MACHINE registry subtree where the Driver registry subkey for the device resides. A driver registry subkey contains the dynamic-link library (DLL) name, device prefix, friendly name, and other device information.
  • dwClientInfo
    [in] Data to store in the Active registry subkey for the device in the ClientInfo registry entry.

**** For Windows Embedded CE:**

The registry path to the **Active** registry subkey for the device is passed in as the *context* parameter to the device's [XXX\_Init (Device Manager)](aa929600\(v=winembedded.60\).md) function. After the value in *dwClientInfo* is 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 **ClientInfo** key.**

Return Value

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

Remarks

ActivateDevice loads a device driver and reads the registry key specified in lpszDevKey to 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\Active registry key, and stores the relevant values there. If you do not specify a device index in the registry subkey specified in lpszDevKey, then ActivateDevice assigns a free index. Then, ActivateDevice loads 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.

Requirements

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

Reference

ActivateDeviceEx
DeactivateDevice
RegisterDevice
XXX_Init (Device Manager)

Concepts

Device Interface Notifications