网站首页  词典首页

请输入您要查询的函数:

 

术语 getvolumepathname
释义 GetVolumePathName
语法:
C++
BOOL WINAPI GetVolumePathName(
__in LPCTSTR lpszFileName,
__out LPTSTR lpszVolumePathName,
__in DWORD cchBufferLength
);
GetVolumePathName功能
检索卷装入点指定安装路径。
如需有关路径名信息,请参见命名一个文件。
参数
lpszFileName [in]
一个输入路径字符串指针。绝对和相对的文件和目录名,例如,"..",是可以接受,这条路。
如果您指定一个相对目录或文件,而无需卷限定符的名称,GetVolumePathName返回当前的音量驱动器号。
如果这个参数是一个空字符串,“”,该功能失败,但最后一个错误是设置为ERROR_SUCCESS。
lpszVolumePathName [out]
一个字符串,收卷装入点输入路径的指针。
cchBufferLength [in]
输出缓冲区的长度,在TCHARs。
返回值
如果函数成功,返回值为非零。
如果函数失败,返回值是零。为了获得更多错误信息,调用GetLastError。
备注
如果指定的路径获得通过,GetVolumePathName返回路径卷装入点,这意味着它返回卷的根在指定的路径终点的位置。
例如,假定您有卷D安装在C:\\产妇和新生儿破伤风\\ Ddrive和数量位置安装在C:\\产妇和新生儿破伤风\\ Ddrive \\产妇和新生儿破伤风\\ Edrive。还假定您有一个文件位置的路径:\\目录的\\子目录\\ MyFile的。如果传递的“C:\\产妇和新生儿破伤风\\ Ddrive \\产妇和新生儿破伤风\\ Edrive \\处长\\子目录\\ MyFile的”字符串GetVolumePathName,它将返回路径“C:\\产妇和新生儿破伤风\\ Ddrive \\产妇和新生儿破伤风\\ Edrive”。
如果任何一个相对目录或文件是没有卷预选赛获得通过,该函数返回当前的音量驱动器号。当前卷驱动器号,也返回如果一个无效的文件或目录名称是没有一个有效的数量限定规定。如果有一个有效量符,并给出该卷存在,但一个无效的文件或目录指定名称,该函数会取得成功,该卷的名字将被退还。举例来说,看到这个题目的例子节。
您必须指定一个有效的Win32命名空间的路径。如果您指定一个NT命名空间的路径,例如,“\\ DosDevices \\高:”或“\\设备\\ HardDiskVolume6”,该函数返回当前的音量驱动器号,而不是该新台币命名空间的路径驱动器号。
您可以指定本地和远程路径。如果您指定一个本地路径,GetVolumePathName返回一个完整路径的前缀是最长前缀,表示一个卷。
如果指定网络共享,GetVolumePathName返回的最短路径的GetDriveType返回DRIVE_REMOTE,这意味着该路径是一个远程驱动器存在,而当前的用户可以访问验证。
有一些特殊情况下不返回一个尾部反斜杠。这些发生在输出缓冲区的长度是一个字符太短。例如,如果lpszFileNameis C:和lpszVolumePathNameis 4个字符,返回值为“C:\\”,但如果lpszVolumePathName是3个字符,返回值为“C:”。更安全,但速度较慢的方式来设置返回缓冲区的大小是调用GetFullPathName函数,然后确保缓冲区大小至少作为完整路径相同大小GetFullPathName回报。如果输出缓冲区多个字符太短,该函数将失败并返回一个错误。
尾随路径元素
尾随路径是无效的元素将被忽略。对于远程路径,整个路径(不只是尾随元素)被认为是无效的,如果下列条件之一:
路径格式不正确。
该路径不存在。
当前用户没有访问的路径。
交接点,并展开文件夹
如果指定的路径遍历一个交接点,GetVolumePathName返回卷一个结点是指。例如,如果W:\\艾迪尔是一个连接点到C点:\\艾迪尔,然后GetVolumePathName在W调用:\\艾迪尔\\ Afile回报的“C:\\”。如果指定的路径会通过多个连接点,整个链次之,GetVolumePathName返回的卷链中的最后交接点,是指。
如果远程路径安装文件夹或指定交界点的路径分析为远程路径和文件夹或安装联接点被忽略。例如,如果C:\\ Dir_C链接到D:\\ Dir_D和C:被映射到X:在远程计算机上,调用GetVolumePathName并指定X:在远程计算机上的回报\\ Dir_C X:\\。
实例
对于下面的例子集,美:被映射到远程计算机\\ \\ YourComputer \\ C $和Q是本地驱动器。
返回指定pathFunction
\\ \\ YourComputer \\加元\\窗口\\ \\ YourComputer \\加元\\
\\ \\?\\的UNC \\ YourComputer \\加元\\窗口\\ \\?\\的UNC \\ YourComputer \\加元\\
问:\\ WindowsQ:\\
\\ \\?\\问:\\窗口\\ \\?\\问:\\
\\ \\。\\问:\\的Windows \\ \\。\\问:\\
\\ \\?\\的UNC \\宽:\\ WindowsFALSE,错误123,因为一个指定的远程路径是无效的;糯$共享不存在或没有授予用户访问。
?:\\ COM2端口(即存在)\\ \\。\\ COM2端口\\
?:\\串口3(不存在),错误123错误的,因为一个不存在的COM装置被指定。
对于下面的例子设置,路径包含无效尾随路径元素。
返回指定pathFunction
摹:\\无效(无效的路径)摹:\\
\\ \\。\\我:\\ AAA级\\无效(无效的路径)\\ \\。\\我:\\
\\ \\ YourComputer \\加元\\无效(无效尾随路径元素)\\ \\ YourComputer \\加元\\
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinBase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode和ANSI namesGetVolumePathNameW(Unicode)和GetVolumePathNameA(ANSI)的
参见
DeleteVolumeMountPoint
GetFullPathName
GetVolumeNameForVolumeMountPoint
SetVolumeMountPoint
卷管理功能
卷装入点
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年9月3日
==英文原文==GetVolumePathName Function
Retrieves the volume mount point where the specified path is mounted.
For more information about path names, see Naming a File .
Syntax
C++
BOOL WINAPI GetVolumePathName(
__in LPCTSTR lpszFileName,
__out LPTSTR lpszVolumePathName,
__in DWORD cchBufferLength
);
Parameters
lpszFileName [in]
A pointer to the input path string. Both absolute and relative file and directory names, for example "..", are acceptable in this path.
If you specify a relative directory or file name without a volume qualifier, GetVolumePathName returns the drive letter of the current volume.
If this parameter is an empty string, "", the function fails but the last error is set to ERROR_SUCCESS.
lpszVolumePathName [out]
A pointer to a string that receives the volume mount point for the input path.
cchBufferLength [in]
The length of the output buffer, in TCHARs.
Return Value
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
If a specified path is passed, GetVolumePathName returns the path to the volume mount point, which means that it returns the root of the volume where the end point of the specified path is located.
For example, assume that you have volume D mounted at C:\\Mnt\\Ddrive and volume E mounted at C:\\Mnt\\Ddrive\\Mnt\\Edrive. Also assume that you have a file with the path E:\\Dir\\Subdir\\MyFile. If you pass the "C:\\Mnt\\Ddrive\\Mnt\\Edrive\\Dir\\Subdir\\MyFile" string to GetVolumePathName, it returns the path "C:\\Mnt\\Ddrive\\Mnt\\Edrive".
If either a relative directory or a file is passed without a volume qualifier, the function returns the drive letter of the current volume. The drive letter of the current volume is also returned if an invalid file or directory name is specified without a valid volume qualifier. If a valid volume specifier is given, and the volume exists, but an invalid file or directory name is specified, the function will succeed and that volume name will be returned. For examples, see the Examples section of this topic.
You must specify a valid Win32 namespace path. If you specify an NT namespace path, for example, "\\DosDevices\\H:" or "\\Device\\HardDiskVolume6", the function returns the drive letter of the current volume, not the drive letter of that NT namespace path.
You can specify both local and remote paths. If you specify a local path, GetVolumePathName returns a full path whose prefix is the longest prefix that represents a volume.
If a network share is specified, GetVolumePathName returns the shortest path for which GetDriveType returns DRIVE_REMOTE, which means that the path is validated as a remote drive that exists, which the current user can access.
There are certain special cases that do not return a trailing backslash. These occur when the output buffer length is one character too short. For example, if lpszFileNameis C: and lpszVolumePathNameis 4 characters long, the value returned is "C:\\"; however, if lpszVolumePathName is 3 characters long, the value returned is "C:". A safer but slower way to set the size of the return buffer is to call the GetFullPathName function, and then make sure that the buffer size is at least the same size as the full path that GetFullPathName returns. If the output buffer is more than one character too short, the function will fail and return an error.
Trailing Path Elements
Trailing path elements that are invalid are ignored. For remote paths, the entire path (not just trailing elements) is considered invalid if one of the following conditions is true:
The path is not formed correctly.
The path does not exist.
The current user does not have access to the path.
Junction Points and Mounted Folders
If the specified path traverses a junction point, GetVolumePathName returns the volume to which the junction point refers. For example, if W:\\Adir is a junction point that points to C:\\Adir, then GetVolumePathName invoked on W:\\Adir\\Afile returns "C:\\". If the specified path traverses multiple junction points, the entire chain is followed, and GetVolumePathName returns the volume to which the last junction point in the chain refers.
If a remote path to a mounted folder or junction point is specified, the path is parsed as a remote path, and the mounted folder or junction point are ignored. For example if C:\\Dir_C is linked to D:\\Dir_D and C: is mapped to X: on a remote computer, calling GetVolumePathName and specifying X:\\Dir_C on the remote computer returns X:\\.
Examples
For the following set of examples, U: is mapped to the remote computer \\\\YourComputer\\C$, and Q is a local drive.
Specified pathFunction returns
\\\\YourComputer\\C$\\Windows\\\\YourComputer\\C$\\
\\\\?\\UNC\\YourComputer\\C$\\Windows\\\\?\\UNC\\YourComputer\\C$\\
Q:\\WindowsQ:\\
\\\\?\\Q:\\Windows\\\\?\\Q:\\
\\\\.\\Q:\\Windows\\\\.\\Q:\\
\\\\?\\UNC\\W:\\WindowsFALSE with error 123 because a specified remote path was not valid; W$ share does not exist or no user access granted.
C:\\COM2 (which exists)\\\\.\\COM2\\
C:\\COM3 (non-existent)FALSE with error 123 because a non-existent COM device was specified.

For the following set of examples, the paths contain invalid trailing path elements.
Specified pathFunction returns
G:\\invalid (invalid path)G:\\
\\\\.\\I:\\aaa\\invalid (invalid path)\\\\.\\I:\\
\\\\YourComputer\\C$\\invalid(invalid trailing path element)\\\\YourComputer\\C$\\

Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinBase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode and ANSI namesGetVolumePathNameW (Unicode) and GetVolumePathNameA (ANSI)
See Also
DeleteVolumeMountPoint
GetFullPathName
GetVolumeNameForVolumeMountPoint
SetVolumeMountPoint
Volume Management Functions
Volume Mount Points
Send comments about this topic to Microsoft
Build date: 9/3/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa364996(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 13:21:11