Skip to content

Latest commit

 

History

History
26 lines (18 loc) · 2.06 KB

opening-a-device-s-hardware-key.md

File metadata and controls

26 lines (18 loc) · 2.06 KB
title description keywords ms.date
Opening a Device's Hardware Key
Provides information about opening a device's hardware key.
hardware keys WDK device installations , opening
opening hardware keys WDK device installations
08/15/2022

Opening a device's hardware key

A hardware key is device-specific registry subkey that contains information about the device. You must not directly open a device's hardware key. As with any registry key, the location or format of these keys might change between different versions of Windows.

Note

You should open a device's hardware key only after the corresponding device has been found. For more information about this procedure, see Enumerating Installed Devices.

To open or create a device's hardware key, follow these guidelines:

Note

You must set the parameter where you provide the requested security access to the minimal access permissions that are required. You must not set this parameter to KEY_ALL_ACCESS. For more information about how to specify access permissions for registry access, see Accessing Registry Keys Safely.

  • To open an existing hardware key, use CM_Open_DevNode_Key with a Disposition of RegDisposition_OpenExisting and ulFlags containing CM_REGISTRY_HARDWARE or use SetupDiOpenDevRegKey and KeyType parameter of DIREG_DEV.

  • To create a hardware key, use CM_Open_DevNode_Key with a Disposition of RegDisposition_OpenAlways and ulFlags containing CM_REGISTRY_HARDWARE or use SetupDiCreateDevRegKey and KeyType parameter of DIREG_DEV.

  • Kernel-mode callers should use IoOpenDeviceRegistryKey and set the DevInstKeyType parameter to PLUGPLAY_REGKEY_DEVICE.