SetupDiCreateDeviceInterfaceRegKeyA function

The SetupDiCreateDeviceInterfaceRegKey function creates a registry key for storing information about a device interface and returns a handle to the key.


WINSETUPAPI HKEY SetupDiCreateDeviceInterfaceRegKeyA(
  HDEVINFO                  DeviceInfoSet,
  DWORD                     Reserved,
  REGSAM                    samDesired,
  HINF                      InfHandle,
  PCSTR                     InfSectionName



A handle to a device information set that contains the interface for which to create a registry key. The device information set must not contain remote elements.


A pointer to an SP_DEVICE_INTERFACE_DATA structure that specifies the device interface in DeviceInfoSet. This pointer is possibly returned by SetupDiCreateDeviceInterface.


Reserved. Must be zero.


The registry security access that the caller requests for the key that is being created. For information about registry security access values of type REGSAM, see the Microsoft Windows SDK documentation.


The handle to an open INF file that contains a DDInstall section to be executed for the newly-created key. This parameter is optional and can be NULL. If this parameter is not NULL, InfSectionName must be specified as well.


A pointer to the name of an INF DDInstall section in the INF file that is specified by InfHandle. This section is executed for the newly created key. This parameter is optional and can be NULL. If this parameter is specified, InfHandle must be specified as well.

Return Value

If SetupDiCreateDeviceInterfaceRegKey succeeds, the function returns a handle to the requested registry key in which interface information can be stored and retrieved. If SetupDiCreateDeviceInterfaceRegKey fails, the function returns INVALID_HANDLE_VALUE. Call GetLastError to get extended error information.


The caller of this function must be a member of the Administrators group.

If the requested key for the device interface already exists, SetupDiCreateDeviceInterfaceRegKey returns a handle to that key; otherwise, SetupDiCreateDeviceInterfaceRegKey creates a new nonvolatile registry key for the specified device interface. Callers of this function can store private configuration data for the device interface in this key. The driver for the device can access this key using IoXxx routines.

Close the handle returned from this function by calling RegCloseKey.

For installations that use layout files (specified by the LayoutFile entry in an INF Version section), the layout file must be opened by a call to SetupOpenAppendInfFile (described in Windows SDK documentation) before SetupDiCreateDeviceInterfaceRegKey is called.

The device information set specified by DeviceInfoSet must only contain elements on the local computer.


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

See Also