SetupDiSelectDevice function (setupapi.h)

The SetupDiSelectDevice function is the default handler for the DIF_SELECTDEVICE request.

Syntax

WINSETUPAPI BOOL SetupDiSelectDevice(
  [in]      HDEVINFO         DeviceInfoSet,
  [in, out] PSP_DEVINFO_DATA DeviceInfoData
);

Parameters

[in] DeviceInfoSet

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

[in, out] DeviceInfoData

A pointer to an SP_DEVINFO_DATA structure that specifies the device information element. This parameter is optional and can be NULL. If this parameter is specified, SetupDiSelectDevice selects the driver for the specified device and sets DeviceInfoData.ClassGuid to the GUID of the device setup class for the selected driver. If this parameter is NULL, SetupDiSelectDevice sets the selected driver in the global class driver list for DeviceInfoSet.

Return value

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

Remarks

SetupDiSelectDevice handles the user interface that allows the user to select a driver for the specified device, or a device information set if a device is not specified. By setting the Flags field of the SP_DEVINSTALL_PARAMS structure for the device, or the device information set if a device is not specified, the caller can specify special handling of the user interface, for example, to allow users to select a driver from an OEM installation disk.

Note  Only a class installer should call SetupDiSelectDevice and only in those situations where the class installer must perform driver selection operations after SetupDiSelectDevice completes the default driver selection operation. In such situations, the class installer must directly call SetupDiSelectDevice when the installer processes a DIF_SELECTDEVICE request. For more information about calling the default handler, see Calling Default DIF Code Handlers.
 
SetupDiSelectDevice is primarily designed to select a driver for a device on a local computer before installing the device. Although SetupDiSelectDevice will not fail if the device information set is for a remote computer, the result is of limited use because the device information set cannot subsequently be used with DIF_Xxx installation requests or SetupDiXxx functions that do not support operations on a remote computer. In particular, the device information set cannot be used as input with a DIF_INSTALLDEVICE installation request to install a device on a remote computer.

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
DLL Setupapi.dll

See also

SP_DEVINSTALL_PARAMS

SetupDiCallClassInstaller