Platform SDK: Files and I/O

GetVolumeNameForVolumeMountPoint

The GetVolumeNameForVolumeMountPoint function takes a volume mount point or root directory and returns the corresponding unique volume name.

BOOL GetVolumeNameForVolumeMountPoint(
  LPCTSTR lpszVolumeMountPoint, // volume mount point or directory
  LPTSTR lpszVolumeName,        // volume name buffer
  DWORD cchBufferLength         // size of volume name buffer
);

Parameters

lpszVolumeMountPoint
[in] Pointer to a string that contains either the path of a volume mount point with a trailing backslash (\) or a drive letter indicating a root directory in the form "D:\".
lpszVolumeName
[out] Pointer to a string that receives the volume name. This name is a unique volume name of the form "\\?\Volume{GUID}\" where GUID is the GUID that identifies the volume.
cchBufferLength
[in] Specifies the length, in TCHARs, of the output buffer. A reasonable size for the buffer to accommodate the largest possible volume name is 50 characters.

Return Values

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

The lpszVolumeMountPoint input string may be a drive letter with appended backslash (\), such as "D:\". Alternatively, it may be a path to a volume mount point, again with appended backslash (\), such as "c:\mnt\edrive\".

Use GetVolumeNameForVolumeMountPoint to obtain unique volume names for use with other functions that work with volume mount points and volume mounting. For more information, see Unique Volume Names.

Requirements

  Windows NT/2000: Requires Windows 2000.
  Windows 95/98: Unsupported.
  Header: Declared in Winbase.h; include Windows.h.
  Library: Use Kernel32.lib.
  Unicode: Implemented as Unicode and ANSI versions on Windows 2000.

See Also

File Systems Overview, File System Functions, DeleteVolumeMountPoint, GetVolumePathName, SetVolumeMountPoint