次の方法で共有


OpenDeviceKey (Compact 2013)

3/26/2014

This function opens the device registry key specified by the ActiveKey parameter. The caller of OpenDeviceKey is responsible for closing the registry handle it returns.

Syntax

HKEY OpenDeviceKey(
  LPCTSTR ActiveKey
);

Parameters

  • ActiveKey
    [in] Pointer to the registry key for which to obtain the handle.

Return Value

If successful, this function returns a handle to the device registry key specified by the ActiveKey parameter. If the function is not successful, it returns NULL. To obtain extended error information, call GetLastError.

Remarks

Device drivers loaded by ActivateDeviceEx or ActivateDevice receive a registry key name as the first argument, which is the pContext parameter, of their initialization routine, XXX_Init (Device Manager). This key is created and owned by the Device Manager, but contains a pointer to the device registry key used in the call to ActivateDeviceEx or ActivateDevice. The device registry key can be opened directly using OpenDeviceKey. For example, a device driver might be loaded because it is described in HKEY_LOCAL_MACHINE\Drivers\Builtin\<Driver Name>. The driver's XXX_Init function receives a pointer to its activation key, for example, HKEY_LOCAL_MACHINE\Drivers\Active\04. The activation key's Key value would be Drivers\Builtin\<Driver Name>.

Using OpenDeviceKey is preferable to reading the Key value, defined as DEVLOAD_DEVKEY_VALNAME, from the activation key because the contents of the activation key are dependent on the implementation of the Device Manager.

Requirements

Header

devload.h

Library

coredll.lib

See Also

Reference

Device Manager Functions
ActivateDevice
ActivateDeviceEx
XXX_Init (Device Manager)