Export (0) Print
Expand All
Expand Minimize

SetupDiSetSelectedDriver function

The SetupDiSetSelectedDriver function sets, or resets, the selected driver for a device information element or the selected class driver for a device information set.

Syntax


BOOL SetupDiSetSelectedDriver(
  _In_     HDEVINFO DeviceInfoSet,
  _Inout_  PSP_DEVINFO_DATA DeviceInfoData,
  _Inout_  PSP_DRVINFO_DATA DriverInfoData
);

Parameters

DeviceInfoSet [in]

A handle to the device information set that contains the driver list from which to select a driver for a device information element or for the device information set.

DeviceInfoData [in, out]

A pointer to an SP_DEVINFO_DATA structure that specifies the device information element in DeviceInfoSet. This parameter is optional and can be NULL. If this parameter is specified, SetupDiSetSelectedDriver sets, or resets, the selected driver for the specified device. If this parameter is NULL, SetupDiSetSelectedDriver sets, or resets, the selected class driver for DeviceInfoSet.

DriverInfoData [in, out]

A pointer to an SP_DRVINFO_DATA structure that specifies the driver to be selected. This parameter is optional and can be NULL. If this parameter and DeviceInfoData are supplied, the specified driver must be a member of a driver list that is associated with DeviceInfoData. If this parameter is specified and DeviceInfoData is NULL, the driver must be a member of the global class driver list for DeviceInfoSet. If this parameter is NULL, the selected driver is reset for the device information element, if DeviceInfoData is specified, or the device information set, if DeviceInfoData is NULL.

If the DriverInfoData.Reserved is NULL, the caller is requesting a search for a driver node with the specified parameters (DriverType, Description, and ProviderName). If a match is found, that driver node is selected. The Reserved field is updated on output to reflect the actual driver node where the match was found. If a match is not found, the function fails and a call to GetLastError returns ERROR_INVALID_PARAMETER.

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

If the caller of SetupDiSetSelectedDriver is a member of the Administrators group, the class of the device is set to the class of the selected driver, provided that the two classes are different.

If DriverInfoData is NULL, SetupDiSetSelectedDriver resets the selected driver. As a result, there is no selected driver.

Requirements

Version

Available in Microsoft Windows 2000 and later versions of Windows.

Header

Setupapi.h (include Setupapi.h)

Library

Setupapi.lib

See also

SetupDiGetSelectedDriver

 

 

Send comments about this topic to Microsoft

Show:
© 2014 Microsoft