SetupDiEnumDriverInfoA function (setupapi.h)

The SetupDiEnumDriverInfo function enumerates the members of a driver list.

Syntax

WINSETUPAPI BOOL SetupDiEnumDriverInfoA(
  [in]           HDEVINFO           DeviceInfoSet,
  [in, optional] PSP_DEVINFO_DATA   DeviceInfoData,
  [in]           DWORD              DriverType,
  [in]           DWORD              MemberIndex,
  [out]          PSP_DRVINFO_DATA_A DriverInfoData
);

Parameters

[in] DeviceInfoSet

A handle to the device information set that contains the driver list to enumerate.

[in, optional] DeviceInfoData

A pointer to an SP_DEVINFO_DATA structure that specifies a device information element in DeviceInfoSet. This parameter is optional and can be NULL. If this parameter is specified, SetupDiEnumDriverInfo enumerates a driver list for the specified device. If this parameter is NULL, SetupDiEnumDriverInfo enumerates the global class driver list that is associated with DeviceInfoSet (this list is of type SPDIT_CLASSDRIVER).

[in] DriverType

The type of driver list to enumerate, which must be one of the following values:

SPDIT_CLASSDRIVER

Enumerate a class driver list. This driver list type must be specified if DeviceInfoData is not specified.

SPDIT_COMPATDRIVER

Enumerate a list of compatible drivers for the specified device. This driver list type can be specified only if DeviceInfoData is also specified.

[in] MemberIndex

The zero-based index of the driver information member to retrieve.

[out] DriverInfoData

A pointer to a caller-initialized SP_DRVINFO_DATA structure that receives information about the enumerated driver. The caller must set DriverInfoData.cbSize to sizeof(SP_DRVINFO_DATA) before calling SetupDiEnumDriverInfo. If the cbSize member is not properly set, SetupDiEnumDriverInfo will return FALSE.

Return value

The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be retrieved with a call to GetLastError.

Remarks

To enumerate driver information set members, an installer should first call SetupDiEnumDriverInfo with the MemberIndex parameter set to 0. It should then increment MemberIndex and call SetupDiEnumDriverInfo until there are no more values. When there are no more values, the function fails and a call to GetLastError returns ERROR_NO_MORE_ITEMS.

If you do not properly initialize the cbSize member of the SP_DRVINFO_DATA structure that is supplied by the pointer DriverInfoData, the function will fail and log the error ERROR_INVALID_USER_BUFFER.

To build a list of drivers associated with a specific device or with the global class driver list for a device information set first use SetupDiBuildDriverInfoList then pass that list to SetupDiEnumDriverInfo.

Note

The setupapi.h header defines SetupDiEnumDriverInfo 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.

Requirements

Requirement Value
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

SetupDiBuildDriverInfoList