How to get the volume GUID

后端 未结 2 490
無奈伤痛
無奈伤痛 2021-01-22 06:39

I am using win32 api with C++.

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

My device looks like this:



        
相关标签:
2条回答
  • 2021-01-22 07:02

    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.

    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().

    0 讨论(0)
  • 2021-01-22 07:03

    Have you considered querying the WMI for it? Let me know if you need details on how to do that.

    0 讨论(0)
提交回复
热议问题