The SetupDiCreateDeviceInfo function creates a new device information element and adds it as a new member to the specified device information set.
WINSETUPAPI BOOL SetupDiCreateDeviceInfoA( HDEVINFO DeviceInfoSet, PCSTR DeviceName, CONST GUID *ClassGuid, PCSTR DeviceDescription, HWND hwndParent, DWORD CreationFlags, PSP_DEVINFO_DATA DeviceInfoData );
A handle to the device information set for the local computer.
A pointer to a NULL-terminated string that supplies either a full device instance ID (for example, "Root*PNP0500\0000") or a root-enumerated device ID without the enumerator prefix and instance identifier suffix (for example, "*PNP0500"). The root-enumerated device identifier can be used only if the DICD_GENERATE_ID flag is specified in the CreationFlags parameter.
A pointer to the device setup class GUID for the device. If the device setup class of the device is not known, set *ClassGuid to a GUID_NULL structure.
A pointer to a NULL-terminated string that supplies the text description of the device. This pointer is optional and can be NULL.
A handle to the top-level window to use for any user interface that is related to installing the device. This handle is optional and can be NULL.
A variable of type DWORD that controls how the device information element is created. Can be a combination of the following values:
Call SetupDiGetDeviceInstanceId to retrieve the device instance ID that was generated for this device information element.
If this flag is specified, the resulting device information element inherits the class driver list, if any, associated with the device information set. In addition, if there is a selected driver for the device information set, that same driver is selected for the new device information element.
A pointer to a SP_DEVINFO_DATA structure that receives the new device information element. This pointer is optional and can be NULL. If the structure is supplied, the caller must set the cbSize member of this structure to sizeof(SP_DEVINFO_DATA) before calling the function. For more information, see the following Remarks section.
The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved by making a call to GetLastError.
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 computer.
|Windows version||Available in Microsoft Windows 2000 and later versions of Windows.|
|Header||setupapi.h (include Setupapi.h)|