I am developing C# application which needs to find any USB port is free for use or not.
Is there any C# class or WMI query to determine USB Port is free for use or not?
Suppose, If a machine has 5 USB ports and out of which 2 are already occupied by mouse ,keyboard and remaining 3 are free. So I need to identify these ports which are not in use.
Is there any win32 class for this so I can use P/Invoke
Regards,
Amol.
Take a look at that answer. I think you need to inspect Availability
property of each Win32_USBHub to determine if device is connected to that port. However, there may be difficulties with USB hubs.
if ((int)device.GetPropertyValue("Availability")>3)
//port is free
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