在WinXP中查找哪个驱动器对应于哪个USB大容量存储设备 [英] Find which drive corresponds to which USB mass storage device in WinXP

查看:141
本文介绍了在WinXP中查找哪个驱动器对应于哪个USB大容量存储设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有多个USB驱动器连接到WinXP SP3计算机,我需要以编程的方式区分它们-我需要找到哪个驱动器号对应于哪个设备(在这种情况下,一个设备〜一卷).我可以使用mountvol来获取其卷ID和驱动器号,如下所示:

C:\WINDOWS\> mountvol
\\?\Volume{bdb681b2-1ddf-11dd-bf71-806d6172696f}\
    C:\

\\?\Volume{6a8784f8-7406-11dd-a8c3-001e8c829b67}\
    A:\

此外,使用 devcon 或设备管理器,我可以看到设备ID:

C:\WINDOWS\> devcon resources *STOR*
STORAGE\REMOVABLEMEDIA\7&190C24E5&0&RM
    Name: Generic volume
STORAGE\VOLUME\1&30A96598&0&SIGNATURED84ED84EOFFSET7E00LENGTH2543150400
    Name: Generic volume
USBSTOR\DISK&VEN_KINGSTON&PROD_DATATRAVELER2.0&REV_1.00\0803240752536&0
    Name: Kingston DataTraveler2.0 USB Device

但是,我还没有找到一种方法来链接设备ID和卷ID/字母,就像安全删除硬件"对话框一样(因此我认为是可能的):


(来源: piskvor.org )

如您所见,这些是我在devcon中看到的相同设备,并且是mountvol看到的相同卷;但到目前为止,我还没有找到它们之间的链接.

我发现了一些相关

@ MSalters 的答案看起来很有希望:在XP上,HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices具有REG_BINARY\DosDevices\x:(其中x是[AZ]);注释是正确设备的(UTF-16)名称(例如
\DosDevices\A: ="\??\STORAGE#RemovableMedia#7&190c24e5&0&RM#{53f5630d-b6bf-11d0-94f2-00a0c91efb8b}\",对应于
STORAGE\REMOVABLEMEDIA\7&190C24E5&0&RM在设备列表的上方).

会看看那是不是要走的路.

解决方案

这是一个不平凡的问题.据我所知,目前还没有官方的API.因此,您需要一个未公开说明的API:注册表. HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices包含驱动器号和卷ID的条目.如果查看实际数据,您会发现它可以识别驱动器.将二进制数据视为Unicode字符串.它将指向HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\ENUM\.但是,XP和Vista在此处引用的子项以及如何引用方面完全不同. (Vista比较容易,所以请先尝试.)

I have several USB drives connected to a WinXP SP3 computer, and I need to tell them apart programatically - I need to find which drive letter corresponds to which device (in this case, one device ~ one volume). I can get their Volume IDs and drive letters using mountvol, looking something like this:

C:\WINDOWS\> mountvol
\\?\Volume{bdb681b2-1ddf-11dd-bf71-806d6172696f}\
    C:\

\\?\Volume{6a8784f8-7406-11dd-a8c3-001e8c829b67}\
    A:\

Also, using devcon or the Device Manager, I can see the device IDs:

C:\WINDOWS\> devcon resources *STOR*
STORAGE\REMOVABLEMEDIA\7&190C24E5&0&RM
    Name: Generic volume
STORAGE\VOLUME\1&30A96598&0&SIGNATURED84ED84EOFFSET7E00LENGTH2543150400
    Name: Generic volume
USBSTOR\DISK&VEN_KINGSTON&PROD_DATATRAVELER2.0&REV_1.00\0803240752536&0
    Name: Kingston DataTraveler2.0 USB Device

However, I haven't found a way to link the device ID and the volume ID/letter, like the "Safely remove hardware" dialog does (therefore I assume it's possible):


(source: piskvor.org)

As you may see, these are the same devices that I see in devcon and the same volume that mountvol sees; but so far I haven't found the link between them.

I've found some related questions, but those seem to use the approach "whatever you find first is your USB device", which is not very useful in my case, since there will be several similar devices (same vendor, often same product type) connected.


Edit:

@MSalters' answer looks promising: On XP, HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices has REG_BINARY values \DosDevices\x: (where x is [A-Z]); the comment is (UTF-16) name of the correct device (e.g.
\DosDevices\A: = "\??\STORAGE#RemovableMedia#7&190c24e5&0&RM#{53f5630d-b6bf-11d0-94f2-00a0c91efb8b}\", which corresponds to
STORAGE\REMOVABLEMEDIA\7&190C24E5&0&RM seen above in the device list).

Will see if that's the way to go.

解决方案

It's a non-trivial question. There is no official API for it, as far as I can tell. So, you need an undocumented API: the registry. HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices contains entries for both drive letters and volume IDs. If you look at the actual data, you'll find that it identifies the drive. Look at the binary data as a Unicode string. It will point you to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\ENUM\. However, XP and Vista differ in exactly what subkeys are referenced there, and how. (Vista is easier, so try that first).

这篇关于在WinXP中查找哪个驱动器对应于哪个USB大容量存储设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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