I'm trying to make an application that can disable/enable USB ports in some conditions. I did my research and found all functions that I need. In the enable/disable function I must send the ClassGuid variable as a parameter, but I can't get the ClassGuid variable when I was trying to get device information variables. I can't change that enable/disable function.
Here is my function that gives me device information variables:
static List<ManagementBaseObject> GetDevices()
{
List<ManagementBaseObject> devices = new List<ManagementBaseObject>();
ManagementObjectCollection collection;
using (var searcher = new ManagementObjectSearcher( "SELECT * FROM Win32_PnPEntity"))
collection = searcher.Get();
foreach (var device in collection)
{
devices.Add(device);
}
collection.Dispose();
return devices;
}
I did try to change the searching query, but I couldn't get the ClassGuid.
Here is what I get when I try to get device information variables:
\username\root\cimv2:Win32_PnPEntity.DeviceID="USB\VID_413C&PID_2111&MI_00\6&245229CD&0&0000
How can I fix this problem. If there is no problem how can I get the ClassGuid of a device?