When Insert a device to the system, the bus of the inserted device detects the device identifier, and notifies the management center to add the device. This "device identifier" is used as a type of device. The standby feature must be used to check whether there is a proper driver. The driver installation information is controlled by the INF file. There is a domain in the INF file that identifies the device identifier suitable for the driver. The search process is to search for qualified INF files. Where can I search? In (Windows Server 2003, Windows XP, and Windows 2000)
First, there are two paths to search: 1. windows INF folder; 2. DevicePath in the Registry
Key Value path (with DevicePath
You can search for the registry as a keyword ). It can be inferred from this that after the driver is installed, the INF file will be copied to these two paths. During the search, the system will rank the matching degree for each matching driver, and the driver with the highest ranking will be selected. As for how to rank, here will not repeat, can refer to the http://msdn.microsoft.com/en-us/library/aa477008.aspx . If the appropriate INF file cannot be found during the above process, the system will pop up the "Find new hardware device wizard" page, you need to select the driver location. If you find the appropriate INF file, the system will select the top driver for installation. At this point, the entire search and selection process will be completed. The following describes how to search for and select a driver from a programmer's perspective after inserting a device with no driver installed. 1. When the user-mode PnP management center receives the Driver Installation command of the new device, it creates a new process and calls newdev. dll to install the driver; 2. newdev. dll callSetupDiBuildDriverInfoList
Create a device driver chain and search for the driver and find all possible drivers. This is the driver search process described above. Because this is the first installation, an empty driver chain will be returned. Therefore, newdev. dll will pop up the "Find a new device wizard", asking the user to select the path of the driver. After the user selects it, call it again.SetupDiBuildDriverInfoList
Create a device driver chain. 3. newdev. dll callSetupDiCallClassInstaller
Sends a series of DIF requests, including: DIF_SELECTBESTCOMPATDRV
, DIF_ALLOW_INSTALL
, DIF_INSTALLDEVICEFILES
, DIF_REGISTER_COINSTALLERS
, DIF_INSTALLINTERFACES
, DIF_INSTALLDEVICE
.. From the command, we can see that processing DIF_SELECTBESTCOMPATDRV
The request is the process of selecting the most matched driver.SetupDiEnumDriverInfo
AndSetupDiGetDriverInstallParams
Give examples of the driver and its parameters, and callSetupDiSetSelectedDriver
Select the driver. |