Platform SDK: Files and I/O |
Two factors can make it hard to reliably mount a specific volume at a specified volume mount point across operating system restarts. One factor is that two different volumes can have the same label, which makes them indistinguishable except by drive letter. The other factor is that drive letters do not necessarily remain the same. If a computer's administrator does not use the Disk Administrator to enforce drive letters, then drive letters can change as drives are removed from or added to the system.
To solve this problem, the system refers to volumes to be mounted with unique volume names. These are strings of this form:
"\\?\Volume{GUID}\"
where GUID is a globally unique identifier (GUID) that identifies the volume. The \\?\ turns off path parsing and is ignored as part of the path, as discussed in Path Lengths. Note the trailing backslash. All volume mount point functions that take a unique volume name as a parameter require the trailing backslash; all volume mount point functions that return a unique volume name provide the trailing backslash. You can use CreateFile to open a volume by referring to its unique volume name, but without a trailing backslash. When using CreateFile, a unique volume name with a backslash refers to the root directory of the volume.
The operating system assigns a unique volume name to a volume when the computer first encounters it, for example during formatting or installation. The volume mount point functions use unique volume names to refer to volumes. To learn the unique volume name of any drive, use the GetVolumeNameForVolumeMountPoint function.