Platform SDK: Files and I/O

GetVolumePathName

The GetVolumePathName function returns the volume mount point at which the specified path is mounted.

BOOL GetVolumePathName(
  LPCTSTR lpszFileName,         // file path
  LPTSTR lpszVolumePathName,    // volume mount point
  DWORD cchBufferLength         // size of buffer
);

Parameters

lpszFileName
[in] Specifies the input path string. Both absolute and relative file and directory names, such as ".", are acceptable in this path.
lpszVolumePathName
[out] Pointer to a string that receives the volume mount point for the input path.
cchBufferLength
[in] Specifies the length, in TCHARs, of the output buffer.

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

Passed a specified path, GetVolumePathName returns the path to the volume mount point. In other words, it returns the root of the volume where the end point of the specified path resides.

For example, assume you have volume D mounted at C:\Mnt\Ddrive and volume E mounted at C:\Mnt\Ddrive\Mnt\Edrive. Assume you have a file with the path E:\Dir\Subdir\MyFile. If you pass GetVolumePathName the input string "C:\Mnt\Ddrive\Mnt\Edrive\Dir\Subdir\MyFile", it returns the output path "C:\Mnt\Ddrive\Mnt\Edrive".

The length of the path returned by this call always is less than or equal to that of the path passed in. A slower but safer way to set the size of the return buffer is to call the GetFullPathName function and then make sure that the buffer is at least as big as the full path GetFullPathName returns.

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, GetFullPathName, GetVolumeNameForVolumeMountPoint, SetVolumeMountPoint