This article lists the steps and some tips to help the OEM driver developer write an "uninstall" package that safely removes .inf files from the system. You have to have administrative credentials to complete these steps.
To remove .inf files, follow these steps:
Note Microsoft recommends that you leave your driver files where they are, if possible, even after you remove your value added applications and .inf files. Other devices and drivers on the system may reference your driver and will stop functioning correctly if the driver files are removed.
Retrieve the path and file name of your .inf file:
The .inf files are located in the %Windir%\Inf folder, and are accompanied by a system-maintained .pnf file with the same root name. When third-party drivers are installed correctly, the .inf is renamed to Oemxx.inf (where xx is a sequential number) to make sure that there are no name conflicts with drivers that are included with the product and with other third-party drivers. You can find the installed name of your driver by using the SetupCopyOEMInf function with the SP_COPY_REPLACEONLY flag and the full path name to your original .inf file (SetupCopyOEMInf is documented in the operating system SDK).
If the original .inf file has been moved, use the full path name to the new location of your .inf file. If the original .inf does not exist on the system, you have to enumerate all the Oemxx.inf files. In each one, check the Provider, DriverVer, Hardware IDs, and other properties to identify the .inf files that you must remove. There is code that does the enumeration and details retrieval in the FindCurrentDriver routine in Dump.cpp of the DevCon sample code (in the Windows Driver Development Kit under Src\Setup\Devcon).
You can also retrieve the Oemxx.inf name from the "InfPath" REG_SZ value under the associated device's driver key, before the device has been removed.
For Windows XP and later versions, use SetupDiBuildDriverInfoList with DeviceInstallParams.FlagsEx set to DI_FLAGSEX_INSTALLEDDRIVER to obtain details about the installed driver.
For Windows 2000, use SetupDiOpenDevRegKey to find the key.
Remove the .inf file and associated files.
On Windows XP and later operating systems, after you have the actual name of the .inf file in the \Inf folder, you can use SetupUninstallOEMInf to correctly remove it.
On Windows 2000, follow these steps:
Enumerate all the devices and make sure that none are using your driver.
Use DeleteFile to remove only the .pnf files from the %Windir%\Inf folder.
Use DeleteFile to finally remove the .inf files from the %Windir%\Inf folder.