积极答复者
如何判断指定的移动设备

问题
答案
-
通过你进一步的描述,我想你应该是在找一个类似GUID的东西,那么你可以试试WMI : Win32_DiskDrive http://msdn.microsoft.com/en-us/library/windows/desktop/aa394132(v=vs.85).aspx
你可以试试 Model 属性或者 SerialNumber 属性,但是请注意Windows Server 2003, Windows XP, Windows 2000, and Windows NT 4.0: This property is not available.
这样,如果你得到了同样的Model和SerialNumber,那么你可以认为这是同一个U盘。
希望有用。
Mike Feng
MSDN Community Support | Feedback to us
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- 已标记为答案 StevinAngel 2012年9月11日 15:01
-
根据您给的提示我查了下使用如下方式可以解决问题。
通过上面这种方式可以获取到USB的信息,获取到的USB的ID就是一个唯一的表示。ManagementClass cimobject = new ManagementClass("Win32_DiskDrive"); ManagementObjectCollection moc = cimobject.GetInstances(); foreach (ManagementObject mo in moc) { if (mo.Properties["InterfaceType"].Value.ToString() == "USB") { string strName = mo.Properties["Caption"].Value.ToString();//USB设备的名称 string strSize = mo.Properties["Size"].Value.ToString(); //USB设备的容量
string[] info = mo.Properties["PNPDeviceID"].Value.ToString().Split('&'); string[] xx = info[3].Split('\\'); string strUsbID = xx[1]; //USB的ID xx = xx[0].Split('_'); xx = info[1].Split('_'); string strCompany = xx[1]; //USB制造商 } } }
- 已标记为答案 StevinAngel 2012年9月11日 15:01
全部回复
-
你好
当你插好后,应该可以通过盘符来选择你需要的移动设备
谢谢
Mike Feng
MSDN Community Support | Feedback to us
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
-
通过你进一步的描述,我想你应该是在找一个类似GUID的东西,那么你可以试试WMI : Win32_DiskDrive http://msdn.microsoft.com/en-us/library/windows/desktop/aa394132(v=vs.85).aspx
你可以试试 Model 属性或者 SerialNumber 属性,但是请注意Windows Server 2003, Windows XP, Windows 2000, and Windows NT 4.0: This property is not available.
这样,如果你得到了同样的Model和SerialNumber,那么你可以认为这是同一个U盘。
希望有用。
Mike Feng
MSDN Community Support | Feedback to us
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- 已标记为答案 StevinAngel 2012年9月11日 15:01
-
根据您给的提示我查了下使用如下方式可以解决问题。
通过上面这种方式可以获取到USB的信息,获取到的USB的ID就是一个唯一的表示。ManagementClass cimobject = new ManagementClass("Win32_DiskDrive"); ManagementObjectCollection moc = cimobject.GetInstances(); foreach (ManagementObject mo in moc) { if (mo.Properties["InterfaceType"].Value.ToString() == "USB") { string strName = mo.Properties["Caption"].Value.ToString();//USB设备的名称 string strSize = mo.Properties["Size"].Value.ToString(); //USB设备的容量
string[] info = mo.Properties["PNPDeviceID"].Value.ToString().Split('&'); string[] xx = info[3].Split('\\'); string strUsbID = xx[1]; //USB的ID xx = xx[0].Split('_'); xx = info[1].Split('_'); string strCompany = xx[1]; //USB制造商 } } }
- 已标记为答案 StevinAngel 2012年9月11日 15:01