My program (which is completely written in C#) has a use case in which the program will need to detect that a specific usb device is installed in the computer. In the case that the usb device is connected, WMI will solve this problem.
However in the case that the device is not connected (nonpresent device), then WMI will not be able to help. I am aware that setupdi will possibly help to resolve this issue, however I am not entirely familiar with C++ and the additional effort to add a marshalling function is quite significant, due to compliance with existing parts of the code.
Hence my question will be whether there is an equivalent c# way to detect the nonpresent devices in the system? I have also tried the registry search method, however the driver is a generic USB driver under HKLM\System\CurrentControlSet\services\WinUSB, and there is no additional information that can be used to identify that the usb driver is corresponding to the specific device we are interested in.
Another possible identifying information is the "Driver Provider" information in the Driver tab in Device manager. The usb device has quite a specific driver provider information that can be used to identify the device. However I do not know the existing API to retrieve this information.
Thank you very much for your assistance and looking forward for any possible solutions
Don't know if this will help or not. It's a couple of snippets of code from something I wrote about 7 years ago, and haven't used since - the project was abandoned. Unfortunately, the whole USB-interfacing is about 700 lines of C# - too much to post here.
As mentioned in a comment in the code, this is based on this: http://www.codeproject.com/Articles/18099/A-USB-HID-Component-for-C
I may have omitted some stuff that's needed - let me know.