次の方法で共有


ActivateDevice (Compact 2013)

3/26/2014

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.

    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) 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

See Also

Reference

Device Manager Functions
ActivateDeviceEx
DeactivateDevice
XXX_Init (Device Manager)

Other Resources

Device Interface Notifications