CM_Open_DevNode_Key function (cfgmgr32.h)

The CM_Open_DevNode_Key function opens a registry key for device-specific configuration information.

Syntax

CMAPI CONFIGRET CM_Open_DevNode_Key(
  [in]  DEVINST        dnDevNode,
  [in]  REGSAM         samDesired,
  [in]  ULONG          ulHardwareProfile,
  [in]  REGDISPOSITION Disposition,
  [out] PHKEY          phkDevice,
  [in]  ULONG          ulFlags
);

Parameters

[in] dnDevNode

Caller-supplied device instance handle that is bound to the local machine

[in] samDesired

The registry security access that is required for the requested key.

[in] ulHardwareProfile

The hardware profile to open if ulFlags includes CM_REGISTRY_CONFIG. If this value is zero, the key for the current hardware profile is opened.

[in] Disposition

Specifies how the registry key is to be opened. May be one of the following values:

RegDisposition_OpenAlways

Open the key if it exists. Otherwise, create the key.

RegDisposition_OpenExisting

Open the key only if it exists.

[out] phkDevice

Pointer to an HKEY that will receive the opened key upon success.

[in] ulFlags

Open device node key flags. Indicates the scope and type of registry storage key to open. Can be a combination of the following flags:

CM_REGISTRY_HARDWARE

Open the device’s hardware key. Do not combine with CM_REGISTRY_SOFTWARE.

CM_REGISTRY_SOFTWARE

Open the device’s software key. Do not combine with CM_REGISTRY_HARDWARE.

CM_REGISTRY_USER

Open the per-user key for the current user. Do not combine with CM_REGISTRY_CONFIG.

CM_REGISTRY_CONFIG

Open the key that stores hardware profile-specific configuration information. Do not combine with CM_REGISTRY_USER.

Return value

If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.

Remarks

Close the handle returned from this function by calling RegCloseKey.

Requirements

Requirement Value
Minimum supported client Available in Microsoft Windows 2000 and later versions of Windows.
Target Platform Universal
Header cfgmgr32.h (include Cfgmgr32.h)
Library Cfgmgr32.lib; OneCoreUAP.lib on Windows 10
DLL CfgMgr32.dll

See also

CM_Delete_DevNode_Key

SetupDiOpenDevRegKey