Skip to content

Latest commit

 

History

History
151 lines (90 loc) · 7.68 KB

nf-setupapi-setupdicreatedeviceinfow.md

File metadata and controls

151 lines (90 loc) · 7.68 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:setupapi.SetupDiCreateDeviceInfoW
SetupDiCreateDeviceInfoW function (setupapi.h)
The SetupDiCreateDeviceInfo function creates a new device information element and adds it as a new member to the specified device information set. (Unicode)
SetupDiCreateDeviceInfo
SetupDiCreateDeviceInfo function [Device and Driver Installation]
SetupDiCreateDeviceInfoW
devinst.setupdicreatedeviceinfo
di-rtns_a4c64729-99b8-44d0-a404-1def9567bf33.xml
setupapi/SetupDiCreateDeviceInfo
devinst\setupdicreatedeviceinfo.htm
devinst
7d42167f-9af4-4aee-b641-a93ade1e3969
12/05/2018
SetupDiCreateDeviceInfo, SetupDiCreateDeviceInfo function [Device and Driver Installation], SetupDiCreateDeviceInfoA, SetupDiCreateDeviceInfoW, devinst.setupdicreatedeviceinfo, di-rtns_a4c64729-99b8-44d0-a404-1def9567bf33.xml, setupapi/SetupDiCreateDeviceInfo
setupapi.h
Setupapi.h
Desktop
Available in Microsoft Windows 2000 and later versions of Windows.
Setupapi.lib
Windows
19H1
SetupDiCreateDeviceInfoW
setupapi/SetupDiCreateDeviceInfoW
c++
APIRef
kbSyntax
LibDef
Setupapi.lib
Setupapi.dll
SetupDiCreateDeviceInfo - SetupDiCreateDeviceInfoW

SetupDiCreateDeviceInfoW function

-description

The SetupDiCreateDeviceInfo function creates a new device information element and adds it as a new member to the specified device information set.

-parameters

-param DeviceInfoSet [in]

A handle to the device information set for the local computer.

-param DeviceName [in]

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.

-param ClassGuid [in]

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.

-param DeviceDescription [in, optional]

A pointer to a NULL-terminated string that supplies the text description of the device. This pointer is optional and can be NULL.

-param hwndParent [in, optional]

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.

-param CreationFlags [in]

A variable of type DWORD that controls how the device information element is created. Can be a combination of the following values:

DICD_GENERATE_ID

If this flag is specified, DeviceName contains only a Root-enumerated device ID and the system uses that ID to generate a full device instance ID for the new device information element.

Call SetupDiGetDeviceInstanceId to retrieve the device instance ID that was generated for this device information element.

DICD_INHERIT_CLASSDRVS

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.

-param DeviceInfoData [out, optional]

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.

- CreationFlags.DICD_GENERATE_ID

If this flag is specified, DeviceName contains only a Root-enumerated device ID and the system uses that ID to generate a full device instance ID for the new device information element.

Call SetupDiGetDeviceInstanceId to retrieve the device instance ID that was generated for this device information element.

- CreationFlags.DICD_INHERIT_CLASSDRVS

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.

-returns

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.

-remarks

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.

Note

The setupapi.h header defines SetupDiCreateDeviceInfo as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

-see-also

SP_DEVINFO_DATA

SetupDiDeleteDeviceInfo

SetupDiEnumDeviceInfo

SetupDiOpenDeviceInfo