I am writing a C# application that monitors and logs the different USB devices that are being connected to a windows system. Using Window's setup API, I am able to get the details such as VID, PID, Hardware Id and Friendly name. What I wanted to ask is is there a way in Windows to check is the connected device is a SmartPhone, or a Printer, or a Mass Storage device, or a Modem?
Note: Using SetupGerDeviceRegistryProperty()
I am able to get the Device Description but for all devices it shows that the Device Description is USB Composite Device.
You can use SetupDiGetDeviceRegistryProperty
with the SPDRP_SERVICE
argument to get the name of the driver installed for the device node. The name of the driver usually indicates what type of device is connected, as long as it is using a standard driver that is part of Windows. You could also use look at the SPDRP_COMPATIBLEIDS
, which are the IDs that are used to select those standard drivers. Actually SPDRP_CLASS
and SPDRP_CLASSGUID
might be the best ones; I think one of those corresponds to the category that the device is displayed under in the Device Manager.
It sounds like your devices are composite devices though, so you will need to access the children of the composite device instead of the composite device itself. One way to do that is to call SetupDiGetClassDevs(NULL, "USB", NULL, 0)
, which will return a device information set that has all the USB devices and all of their children.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With