Platform SDK: Files and I/O |
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 );
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.
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.
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.
File Systems Overview, File System Functions, DeleteVolumeMountPoint, GetFullPathName, GetVolumeNameForVolumeMountPoint, SetVolumeMountPoint