Installers can use the general Setup functions and device installation functions that are provided by SetupAPI to perform installation operations. These functions allow installers to search INF files for compatible drivers, to display driver choices to the user through selection dialog boxes, and to perform the actual driver installation.
Most of the device installation functions rely on information in the SP_DEVINFO_DATA structure to perform installation tasks. Each device is associated with an SP_DEVINFO_DATA structure. You can retrieve a handle (HDEVINFO) to a device information set that contains all installed devices in a particular class by using the SetupDiGetClassDevs function. You can use the SetupDiCreateDeviceInfo function to add a new device to a device information set. You can free all SP_DEVINFO_DATA structures in a device information set by using the SetupDiDestroyDeviceInfoList function. This function also frees any compatible device and class device lists that might have been added to the structure.
By using the SetupDiBuildDriverInfoList function, you can generate a list from which the installer or the user can choose the driver or device to install. SetupDiBuildDriverInfoList creates a list of compatible drivers or a list of all devices of a particular class.
Once you have a list of compatible drivers, you can prompt the user to select from the list by using the SetupDiSelectDevice function. This function displays a dialog box that contains information about each device in the device information set. You can install a selected driver by using the SetupDiInstallDevice function. This function uses information in the driver's INF file to create to any new registry entries required, to set the configuration of the device hardware, and to copy the driver files to the appropriate directories.
An installer might have to examine and set values under the registry key for a device that is about to be installed. You can open the hardware or driver key for a device by using the SetupDiCreateDevRegKey or SetupDiOpenDevRegKey function.
You can remove a device from the system by using the SetupDiRemoveDevice function. This function deletes the device's registry entries and, if possible, stops the device. If the device cannot be dynamically stopped, the function sets flags that eventually cause the user to be prompted to shut down the system.