2014年1月12日 星期日

從 PID/VID 換算出 GUID 值

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;
}

沒有留言:

Iperf3.1.3 使用方法

20190417: 使用 Iperf3.1.3 //-c: TCP client //-w:測試檔案大小 //-i:inteval //-t:times //--omit 代表濾掉前兩個測試值,這樣就可以得到比較好的平均速率 //-R:Downlink ; 不設定 default...