The SetupDiCreateDeviceInfo function creates a new device information element and adds it as a new member to the specified device information set.
WINSETUPAPI BOOL WINAPI
SetupDiCreateDeviceInfo(
IN HDEVINFO DeviceInfoSet,
IN PCTSTR DeviceName,
IN LPGUID ClassGuid,
IN PCTSTR DeviceDescription, OPTIONAL
IN HWND hwndParent, OPTIONAL
IN DWORD CreationFlags,
OUT PSP_DEVINFO_DATA DeviceInfoData OPTIONAL
);
Enum\Root\DeviceName\InstanceID
where InstanceID is a four-digit, base-10 number that is unique among all subkeys under Enum\Root\DeviceName. Call SetupDiGetDeviceInstanceId to find out what ID was generated for this device information element.
The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved with a call to GetLastError.
Declared in setupapi.h. Include setupapi.h.
The caller of this function must be a member of the Administrators group.
If this device instance is being added to a set that has an associated class, the device class must be the same or the call fails. In this case, a call to GetLastError returns ERROR_CLASS_MISMATCH.
If the specified device instance is the same as an existing device instance key in the registry, the call fails. In this case, a call to GetLastError returns ERROR_DEVINST_ALREADY_EXISTS. This occurs only if the DICD_GENERATE_ID flag is not set.
If the new device information element was successfully created but the caller-supplied DeviceInfoData buffer is invalid, the function returns FALSE. In this case, a call to GetLastError returns ERROR_INVALID_USER_BUFFER. However, the device information element will have been added as a new member of the set already.
The DeviceInfoSet must only contain elements on the local machine.
SetupDiDeleteDeviceInfo, SetupDiEnumDeviceInfo, SetupDiOpenDeviceInfo, SP_DEVINFO_DATA