public
string GetGUID(string
VendorID,
string ProductID)
{
string m_GUID =
"";
ManagementObjectCollection USBControllerDeviceCollection =
new ManagementObjectSearcher("SELECT
* FROM Win32_USBControllerDevice").Get();
if (USBControllerDeviceCollection !=
null)
{
foreach (ManagementObject USBControllerDevice in USBControllerDeviceCollection)
{
String Dependent = (USBControllerDevice["Dependent"]
as String).Split(new Char[] { '=' })[1];
if (Dependent.IndexOf(VendorID)
>= 0 && Dependent.IndexOf(ProductID)
>= 0)
{
ManagementObjectCollection PnPEntityCollection =
new ManagementObjectSearcher("SELECT
* FROM Win32_PnPEntity WHERE DeviceID="
+ Dependent).Get();
if (PnPEntityCollection !=
null)
{
foreach (ManagementObject
Entity in PnPEntityCollection)
{
Guid theClassGuid =
new Guid(Entity["ClassGuid"]
as String); // ??安??GUID
m_GUID = theClassGuid.ToString();
return m_GUID;
}
}
}
}
}
return m_GUID;
}
沒有留言:
張貼留言