SetupDiOpenClassRegKeyExA function

The SetupDiOpenClassRegKeyEx function opens the device setup class registry key, the device interface class registry key, or a specific class's subkey. This function opens the specified key on the local computer or on a remote computer.

Syntax

WINSETUPAPI HKEY SetupDiOpenClassRegKeyExA(
  CONST GUID *ClassGuid,
  REGSAM     samDesired,
  DWORD      Flags,
  PCSTR      MachineName,
  PVOID      Reserved
);

Parameters

ClassGuid

A pointer to the GUID of the class whose registry key is to be opened. This parameter is optional and can be NULL. If this parameter is NULL, the root of the class tree (HKLM\SYSTEM\CurrentControlSet\Control\Class) is opened.

samDesired

The registry security access for the key to be opened. For information about registry security access values of type REGSAM, see the Microsoft Windows SDK documentation.

Flags

The type of registry key to be opened, which is specified by one of the following:

DIOCR_INSTALLER

Open a setup class key. If ClassGuid is NULL, open the root key of the class installer branch.

DIOCR_INTERFACE

Open an interface class key. If ClassGuid is NULL, open the root key of the interface class branch.

MachineName

Optionally points to a string that contains the name of a remote computer on which to open the specified key.

Reserved

Reserved. Must be NULL.

Return Value

SetupDiOpenClassRegKeyEx returns a handle to an opened registry key where information about this setup class can be stored/retrieved.

If the function fails, it returns INVALID_HANDLE_VALUE. To get extended error information, call GetLastError.

Remarks

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.

SetupDiOpenClassRegKeyEx does not create a registry key if it does not already exist.

Callers of this function must close the handle returned from this function by calling RegCloseKey.

Requirements

   
Windows version Available in Microsoft Windows 2000 and later versions of Windows.
Target Platform Desktop
Header setupapi.h (include Setupapi.h)
Library Setupapi.lib

See Also

SetupDiCreateDeviceInterfaceRegKey

SetupDiOpenDevRegKey