The SetupDiOpenDevRegKey function opens a registry key for device-specific configuration information.
WINSETUPAPI HKEY SetupDiOpenDevRegKey( HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Scope, DWORD HwProfile, DWORD KeyType, REGSAM samDesired );
A handle to the device information set that contains a device information element that represents the device for which to open a registry key.
A pointer to an SP_DEVINFO_DATA structure that specifies the device information element in DeviceInfoSet.
The scope of the registry key to open. The scope determines where the information is stored. The scope can be global or specific to a hardware profile. The scope is specified by one of the following values:
Open a key to store global configuration information. This information is not specific to a particular hardware profile. This opens a key that is rooted at HKEY_LOCAL_MACHINE. The exact key opened depends on the value of the KeyType parameter.
Open a key to store hardware profile-specific configuration information. This key is rooted at one of the hardware-profile specific branches, instead of HKEY_LOCAL_MACHINE. The exact key opened depends on the value of the KeyType parameter.
A hardware profile value, which is set as follows:
- If Scope is set to DICS_FLAG_CONFIGSPECIFIC, HwProfile specifies the hardware profile of the key that is to be opened.
- If HwProfile is 0, the key for the current hardware profile is opened.
- If Scope is DICS_FLAG_GLOBAL, HwProfile is ignored.
The type of registry storage key to open, which can be one of the following values:
Open a hardware key for the device.
Open a software key for the device.
For more information about a device's hardware and software keys, see Registry Trees and Keys for Devices and Drivers.
The registry security access that is required for the requested key. For information about registry security access values of type REGSAM, see the Microsoft Windows SDK documentation.
If the function is successful, it returns a handle to an opened registry key where private configuration data about this device instance can be stored/retrieved.
If the function fails, it returns INVALID_HANDLE_VALUE. To get extended error information, call GetLastError.
Depending on the value that is passed in the samDesired parameter, it might be necessary for the caller of this function to be a member of the Administrators group.
Close the handle returned from this function by calling RegCloseKey.
The specified device instance must be registered before this function is called. However, be aware that the operating system automatically registers PnP device instances. For information about how to register non-PnP device instances, see SetupDiRegisterDeviceInfo.
|Windows version||Available in Microsoft Windows 2000 and later versions of Windows.|
|Target Platform||DesktopFor universal, call CM_Open_DevNode_Key|
|Header||setupapi.h (include Setupapi.h)|