How can i enumerate a list of all logical volumes on a disk? I want the name of the volume that is suitable for opening with CreateFile.
What have you tried?
I've used the FindFirstVolume/FindNextVolume API to enumerate a list of volumes. It returns a list of names such as:
\\?\Volume{0b777018-3313-11e2-8ccd-806e6f6e6963}\\\?\Volume{0b777019-3313-11e2-8ccd-806e6f6e6963}\\\?\Volume{758a2cf2-cf3a-11e4-8dce-c86000d0b92a}\\\?\Volume{4f81d34b-34f4-11e2-9f6e-c86000d0b92a}\
But none of those volume names are valid volume names. That is, none of those names can be passed to CreateFile to open the volume:
0x00000003 (The system cannot find the path specified)
The question might be how do i convert the thing returned by FindFirstVolume into a volume name?
But the real question is how do i enumerate volumes in the first place?
Why not just use \\.\C:?
I wasn't asking how to hard-code a volume name; i was asking how to enumerate volume names.
Besides, not every volume has a drive letter, e.g.:
\\?\Volume{0b777019-3313-11e2-8ccd-806e6f6e6963}\==>\\.\C:\\?\Volume{758a2cf2-cf3a-11e4-8dce-c86000d0b92a}\==>\\.\D:\\?\Volume{0b777018-3313-11e2-8ccd-806e6f6e6963}\==> the system reserved volume with no drive letter\\?\Volume{4f81d34b-34f4-11e2-9f6e-c86000d0b92a}\==> a CD ROM that is mounted in a folder
I swear there is an API to enumerate volumes.
GetLogicalDriveStrings
The problem with GetLogicalDriveStrings function is that it only returns logical drives:
C:\D:\
and not volumes. In my case it misses two volumes:
- System Reserved
- D:\CDROM
that FindFirstVolume does correctly return.
Aucun commentaire:
Enregistrer un commentaire