Installers can use the device installation functions, provided by the SetupX dynamic-link library, to carry out installation tasks. The device installation functions allow installers to search INF files for compatible drivers, display driver choices to the user through selection dialogs, and perform the actual driver installation.
Nearly all the device installation function rely on the information in the DEVICE_INFO structure to carry out the request tasks. You can create a linked list of these structures for the devices in the given class by using the DiGetClassDevs function. This function fills each structure with information about the individual devices. You can also create a single copy of a structure by using the DiCreateDeviceInfo function. This function lets you explicitly define the content of the structure and is useful for adding devices to the list that the DiGetClassDevs function may not have found. You can free all DEVICE_INFO structures in a list by using the DiDestroyDeviceInfoList function. This function also frees any compatible device and class device lists that may have been added to the structure.
You can generate a list of selections from which the installer or the user can choose the drivers or device to install by using the DiBuildCompatDrvList and DiBuildClassDeviceList functions. DiBuildCompatDrvList creates a list of compatible drivers and DiBuildClassDeviceList creates a list of all devices of a given class. These functions create linked lists of DRIVER_NODE structures that contain information about the drivers and devices the function located in a search of all the INF files on a given path.
Once you have a list of compatible drivers or devices, you can prompt the user to select from the list by using the DiSelectDevice function. This function displays a dialog box to that contains information about each device in the linked list of structures. You can install a selected driver by using the DiInstallDevice function. This function uses information in the given INF file to create any new registry entries required for the device, set the configuration of the device hardware, and copy the driver files to the appropriate directories.
An installer may need 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 DiOpenRegKey function.
You can install a new class of device in the registry by using the DiInstallClass function. This function requires an INF file that contains a valid [ClassInstall] section.
Some device installation functions are intended to be used by system and may not be useful for ordinary installers. You can call the installer for a given class by using the DiCallClassInstaller function. This function is useful if a device installer needs support from the corresponding class installer to complete installation. The function uses the class name to locate, load, and call the appropriate class installer.
You can remove a device entry from the registry by using the DiRemoveDevice function.