Reputation: 552
I have some C# code scanning for plug and play devices and then filtering out 2 USB devices (call them dev1 and dev2) by matching VID and PID.
Now, dev1 is directly connected to a USB port of my laptop, while dev2 is connected to a USB Hub, that is connected to my docking station, that is connected to a different laptop USB port than dev1.
Dev1 and Dev2 are different hardware and VID+PID are therefore different for both. My script does detect the 2 different hardware with the correct (and different) VID+PID.
However, the GUID is the same for both Hardware. How can this be possible? Should they not be always different?
For info, here is how I am extracting the GUID and the VID+PID:
ManagementObjectCollection collection;
using (var searcher = new ManagementObjectSearcher(@"Select * From Win32_PnPEntity"))
collection = searcher.Get();
foreach (var device in collection)
{
string deviceIdValue = (string)device.GetPropertyValue("DeviceID"); // Provides VID and PID
string guidValue = (string)device.GetPropertyValue("ClassGuid"); // Provide the GUID
...
}
Upvotes: 1
Views: 1172
Reputation: 123
Check this link. It lists all the ClassGuid types.
The ClassGuid is not tigh to one piece of hardware, but rather to the type of class your hardware refers to.
For instance, two difference hardware of type USB, will both have the same ClassGuid {36FC9E60-C465-11CF-8056-444553540000} as per reference.
Upvotes: 1
Reputation: 21
That's because ClassGuid is not an object identifier but a class identifier.
If you check out the PnPClass property you'll notice that it is the same when the ClassGuid is the same.
Upvotes: 2