如何获取卷GUID [英] How to get the volume GUID

查看:1346
本文介绍了如何获取卷GUID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是win32 api与 C ++

I am using win32 api with C++.

我想知道如何获得音量GUID使用设备路径。

I would like to know how I can get the volume GUID using a "device path".

我的设备如下所示:

\\?\usb#vid_04f2&pid_0111#5&39fe81e&0&2#{a5dcbf10-6530-11d2-901f-00c04fb951ed}

感谢。

推荐答案

usb\VID_04f2& PID_0111\5& 39fe81e& 0& 2 。这可能是一个大容量存储设备aka磁盘。现在,你的问题是,大容量存储设备实际上没有驱动器号;它是具有驱动器盘符的磁盘上的卷。如果有两个分区,单个USB大容量存储设备可能有两个驱动器盘符。因此,没有直接的函数来获取 卷。

This will be the device with device instance ID usb\VID_04f2&PID_0111\5&39fe81e&0&2. That's probably a mass storage device aka disk. Now, the problem you have is that a mass storage device doesn't actually have a drive letter; it's the volume on that disk which has a drive letter. If there are two partitions, a single USB mass storage device may have two drive letters. So, there's no direct function to get the volume.

看起来你需要枚举设备树根目录 usb\VID_04f2& PID_0111\5& 39fe81e& 0& 2 可查找设备类型为volume的儿童。您获得的DEV_BROADCAST_DEVICEINTERFACE将有一个 dbcc_name 字段,您可以传递到 GetVolumeNameForVolumeMountPoint()

It looks like you need to enumerate the device tree rooted at usb\VID_04f2&PID_0111\5&39fe81e&0&2 to find children with device type "volume". The DEV_BROADCAST_DEVICEINTERFACE you get will have a dbcc_name field that you can pass to GetVolumeNameForVolumeMountPoint().

这篇关于如何获取卷GUID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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