I want to install a third-party libusb driver during a Windows Setup installation. I created this installation with Visual Studio 2010.
I have tried installing this driver through the command line using SetupAPI and DifXAPI, but nothing happens. I expect a window to popup stating that it is an unsigned driver, and you have to click OK to continue. The only way I have got this window to popup is if I used a C# console application and P/Invoke to call the driver install code from DifXApi (pointing to the INF file which looks like it was generated by inf-wizard), and the project needed to be built for x64 (I need this to also work for 32-bit installers). After clicking OK the driver never installed.
The only way this driver correctly installs is if I plug in the hardware via USB, right click the unknown device, and browse to the folder containing the driver DLL file's, sys files, and INF file. How does Windows figure out how to install the driver?
The INF file has driver sections for 32 bit/64 bit/Itanium, but how does Windows know which section to install, and what is Windows doing differently that I am in command line?
I am able to install the drivers on 32-bit and 64-bit Windows with the following code, where
infPath
is the path to the INF file, anddevices
is a list of all the device id's associated with the USB device: