如何获取“设备实例ID” USB闪存盘? [英] How do I get the "Device Instance Id" of USB flash drive?

查看:160
本文介绍了如何获取“设备实例ID” USB闪存盘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

如何获取"设备实例ID" USB闪存盘?

How do I get the "Device Instance Id" of USB flash drive?

完成此操作的WPF C#代码将不胜感激。

WPF C# code to accomplish this will be greatly appreciated.

我正在尝试再次获得上述答案。问题 看来有些人不知道我的意思是"设备实例ID"。 以下是在使用XP操作系统的计算机上找到它的方法:

I'm trying again to get an answer to the above question.  It appears that some do not know what I mean by "Device Instance Id".  Here is how you find it on a computer with the XP operating system:

如果你以错误的方式找到它,你就找不到它。 您必须按照以下步骤操作(在XP上):
$


1)确保将USB闪存盘插入其中一个USB端口。



2)点击"开始"按钮然后右键单击"MyComputer"然后点击"管理"。
$


3)在"计算机管理"中窗口单击"设备管理器"。
$


4)在右侧窗格中展开"磁盘驱动器"。



5)右键点击"USB闪存盘USB设备" (如果没有插入USB闪存盘,则不会在那里。)


6)点击"属性"。

¥ b $ b 7)点击"详细信息"选项卡。



8)下拉列表中应该已经有"设备实例ID"。显示,如果没有,请选择它。



9)下面文本框的内容包含我想要的信息。



同样,如果你以不同的方式到达这个窗口,那么"详细信息"选项卡可能不会出现。



同样,如果您没有将USB闪存驱动器插入计算机,则"USB闪存盘USB设备"可能会出现。不会出现。

If you go to it the wrong way you will not find it.  You have to follow these steps (on XP):

1) Make sure you have a USB flash drive inserted into one of the USB ports.

2) Click "Start" then right click "MyComputer" then click "Manage".

3) In the "Computer Management" window click "Device Manager".

4) In the right pane expand the "Disk drives".

5) Right click on "USB Flash Disk USB Device" (Will NOT be there if no USB Flash drive inserted).

6) Click "Properties".

7) Click the "Details" tab.

8) The drop down should already have "Device Instance Id" showing, if not, select it.

9) The contents of the text box below contain the information I want.

Again, if you get to this window a different way, the "Details" tab may not appear.

Again, if you do not have a USB flash drive plugged into your computer, the "USB Flash Disk USB Device" will not appear.

这是之前的建议,但不起作用。 我需要工作代码,而不是指向如何操作的文本的链接,它们似乎不适用于WPF。 此外,如果确实如此,他们为什么不发布他们使用的实际代码。找不到没有WPF程序的代码
很简单,但没有WPF的代码可以得到我需要的东西。

This is what has been suggested before, but does not work.  I need working code, not links to text that suggests how to do it, they don't seem to work in WPF.  Besides, if it did, why would they not post the actual code they used. Finding code for none WPF programs is simple, but no code for WPF that gets what I need.

这是我已经尝试过的:


    void MainWindow_Loaded(object sender, RoutedEventArgs e)
    {
      ManagementObjectSearcher moSearch = new ManagementObjectSearcher ("Select * from Win32_LogicalDisk where Name='I:'");
      foreach (var mo in moSearch.Get())
      {
        tbID.Text = mo["VolumeSerialNumber"].ToString();
        MessageBox.Show("Device Instance Id: " + tbID.Text);<br/>
       }
    }

推荐答案

你可能想看看
.NET USB库
。 
You might want to take a look at the .NET USB library


这篇关于如何获取“设备实例ID” USB闪存盘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆