Reputation: 5023
I'm installing my driver using dpinst.exe. But before installing my driver I wish to delete all the oem files from inf directory corresponding to my hardware ID.
I want to do this programatically. Please suggest me a way to do this.
**Update :**
I want to do this without device connected as I may pre-install the driver before connecting the device. My device is PNP device.
Upvotes: 1
Views: 4320
Reputation: 169
PhilMY has already posted an excellent answer, which is still relevant. However, it is more than ten years old now, so I wanted to update it with more recent/recommended APIs:
SetupDiEnumDeviceInfo()
and SetupDiGetDeviceRegistryProperty()
to match your hardware IDSetupDiGetDriverInfoDetail()
can be used instead of reading the registry directlyDiUninstallDriver()
on the resulting INF path (Microsoft recommends using it instead of SetupUninstallOEMInf()
. In addition, it returns the needReboot
flag, which may be useful in some scenarios.)#2 is a little tricky as it requires SP_DRVINFO_DATA
on input. To acquire it, one typically needs to call SetupDiBuildDriverInfoList()
and SetupDiEnumDriverInfo()
to iterate through all installed drivers for a particular device (use SPDIT_COMPATDRIVER
flag to enumerate 3rd-party drivers).
It has a significant advantage in scenarios when multiple drivers are suitable for the given device, and this approach allows one to choose exactly which driver to uninstall.
Upvotes: 1
Reputation: 2651
InfPath
Upvotes: 2