网站首页  词典首页

请输入您要查询的函数:

 

术语 getfinalpathnamebyhandle
释义 GetFinalPathNameByHandle
语法:
C++
DWORD WINAPI GetFinalPathNameByHandle(
__in HANDLE hFile,
__out LPTSTR lpszFilePath,
__in DWORD cchFilePath,
__in DWORD dwFlags
);
GetFinalPathNameByHandle功能
检索指定文件的最终路径。
有关文件和路径名信息,请参见命名一个文件。
参数
hFile [in]
句柄到一个文件或目录。
lpszFilePath [out]
阿一个缓冲区,它接收的hFile路径的指针。
cchFilePath [in]
在lpszFilePath的大小,以TCHARS。此值不包括空终止字符。
dwFlags [in]
在返回结果的类型。此参数可以是下列值之一。
ValueMeaning
FILE_NAME_NORMALIZED
0x0Return归一驱动器的名称。这是默认的。
FILE_NAME_OPENED
0x8Return打开的文件名(不归)。
此参数还可以包括下列值之一。
ValueMeaning
VOLUME_NAME_DOS
0x0Return与盘符路径。这是默认的。
VOLUME_NAME_GUID
0x1Return与卷路径的GUID路径,而不是驱动器的名称。
VOLUME_NAME_NONE
0x4Return的无驱动器信息的路径。
VOLUME_NAME_NT
0x2Return与卷设备路径。
返回值
如果函数成功,返回值是字符串的长度lpszFilePath收到TCHARs。此值不会包括终止空字符的大小。
Windows Server 2008和Windows Vista的:对于这一职能,GetFinalPathNameByHandleA,返回值的ANSI版本,包括终止空字符的大小。
如果函数失败,因为lpszFilePath太小举行字符串加上终止空字符,返回值是所需的缓冲区大小,在TCHARs。此值包括终止空字符的大小。
如果该函数的任何其他原因而失败,返回值是零。为了获得更多错误信息,调用GetLastError。
返回codeDescription
ERROR_PATH_NOT_FOUNDCan归还如果您正在搜索的驱动器号和不存在。例如,办理开设的是目前没有装入驱动器,或者如果您创建卷,不为其指定驱动器号。如果卷没有驱动器号,您可以使用卷GUID路径识别它。
这个返回值也可以返回如果您正在寻找的卷GUID的网络共享的路径。卷GUID路径不是网络共享创建。
ERROR_NOT_ENOUGH_MEMORYInsufficient内存来完成该操作。
ERROR_INVALID_PARAMETERInvalid旗指定dwFlags。
备注
最后一个路径是返回的路径时,尚未完全解决的道路。例如,对于一个符号链接名为“c:\\ Tmp文件\\ Mydir的”,它指向的“D:\\ yourdir”,最后的路径将是的“D:\\ yourdir”。
该是这个函数返回字符串使用\\ \\?\\语法。有关更多信息,请参阅CreateFile。
实例
下面的例子演示了GetFinalPathNameByHandle功能我们。
#include
#include
#include
#define BUFSIZE MAX_PATH
void __cdecl _tmain(int argc, TCHAR *argv[])
{
TCHAR Path[BUFSIZE];
HANDLE hFile;
DWORD dwRet;
printf("\\n");
if( argc != 2 )
{
printf("ERROR:\\tIncorrect number of arguments\\n\\n");
printf("%s \\n", argv[0]);
return;
}
hFile = CreateFile(argv[1], // file to open
GENERIC_READ, // open for reading
FILE_SHARE_READ, // share for reading
NULL, // default security
OPEN_EXISTING, // existing file only
FILE_ATTRIBUTE_NORMAL, // normal file
NULL); // no attr. template
if( hFile == INVALID_HANDLE_VALUE)
{
printf("Could not open file (error %d\\n)", GetLastError());
return;
}
dwRet = GetFinalPathNameByHandle( hFile, Path, BUFSIZE, VOLUME_NAME_NT );
if(dwRet < BUFSIZE)
{
_tprintf(TEXT("\\nThe final path is: %s\\n"), Path);
}
else printf("\\nThe required buffer size is %d.\\n", dwRet);
CloseHandle(hFile);
}

要求:
client最低支持Vista
server最低支持 Windows Server 2008
HeaderWinBase.h
LibraryKernel32.lib
DLLKernel32.dll
Unicode和ANSI namesGetFinalPathNameByHandleW(Unicode)和GetFinalPathNameByHandleA(ANSI)的
参见
文件管理函数
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年9月3日
==英文原文==GetFinalPathNameByHandle Function
Retrieves the final path for the specified file.
For more information about file and path names, see Naming a File .
Syntax
C++
DWORD WINAPI GetFinalPathNameByHandle(
__in HANDLE hFile,
__out LPTSTR lpszFilePath,
__in DWORD cchFilePath,
__in DWORD dwFlags
);
Parameters
hFile [in]
A handle to a file or directory.
lpszFilePath [out]
A pointer to a buffer that receives the path of hFile.
cchFilePath [in]
The size of lpszFilePath, in TCHARS. This value does not include a NULL termination character.
dwFlags [in]
The type of result to return. This parameter can be one of the following values.
ValueMeaning
FILE_NAME_NORMALIZED
0x0Return the normalized drive name. This is the default.
FILE_NAME_OPENED
0x8Return the opened file name (not normalized).

This parameter can also include one of the following values.
ValueMeaning
VOLUME_NAME_DOS
0x0Return the path with the drive letter. This is the default.
VOLUME_NAME_GUID
0x1Return the path with a volume GUID path instead of the drive name.
VOLUME_NAME_NONE
0x4Return the path with no drive information.
VOLUME_NAME_NT
0x2Return the path with the volume device path.

Return Value
If the function succeeds, the return value is the length of the string received by lpszFilePath, in TCHARs. This value does not include the size of the terminating null character.
Windows Server 2008 and Windows Vista: For the ANSI version of this function, GetFinalPathNameByHandleA, the return value includes the size of the terminating null character.
If the function fails because lpszFilePath is too small to hold the string plus the terminating null character, the return value is the required buffer size, in TCHARs. This value includes the size of the terminating null character.
If the function fails for any other reason, the return value is zero. To get extended error information, call GetLastError .
Return codeDescription
ERROR_PATH_NOT_FOUNDCan be returned if you are searching for a drive letter and one does not exist. For example, the handle was opened on a drive that is not currently mounted, or if you create a volume and do not assign it a drive letter. If a volume has no drive letter, you can use the volume GUID path to identify it.
This return value can also be returned if you are searching for a volume GUID path on a network share. Volume GUID paths are not created for network shares.
ERROR_NOT_ENOUGH_MEMORYInsufficient memory to complete the operation.
ERROR_INVALID_PARAMETERInvalid flags were specified for dwFlags.

Remarks
A final path is the path that is returned when a path is fully resolved. For example, for a symbolic link named "C:\\tmp\\mydir" that points to "D:\\yourdir", the final path would be "D:\\yourdir".
The string that is returned by this function uses the \\\\?\\ syntax. For more information, see CreateFile .
Examples
The following example demonstrates the us of the GetFinalPathNameByHandle function.
#include
#include
#include
#define BUFSIZE MAX_PATH
void __cdecl _tmain(int argc, TCHAR *argv[])
{
TCHAR Path[BUFSIZE];
HANDLE hFile;
DWORD dwRet;
printf("\\n");
if( argc != 2 )
{
printf("ERROR:\\tIncorrect number of arguments\\n\\n");
printf("%s \\n", argv[0]);
return;
}
hFile = CreateFile(argv[1], // file to open
GENERIC_READ, // open for reading
FILE_SHARE_READ, // share for reading
NULL, // default security
OPEN_EXISTING, // existing file only
FILE_ATTRIBUTE_NORMAL, // normal file
NULL); // no attr. template
if( hFile == INVALID_HANDLE_VALUE)
{
printf("Could not open file (error %d\\n)", GetLastError());
return;
}
dwRet = GetFinalPathNameByHandle( hFile, Path, BUFSIZE, VOLUME_NAME_NT );
if(dwRet < BUFSIZE)
{
_tprintf(TEXT("\\nThe final path is: %s\\n"), Path);
}
else printf("\\nThe required buffer size is %d.\\n", dwRet);
CloseHandle(hFile);
}
Requirements
Minimum supported clientWindows Vista
Minimum supported serverWindows Server 2008
HeaderWinBase.h
LibraryKernel32.lib
DLLKernel32.dll
Unicode and ANSI namesGetFinalPathNameByHandleW (Unicode) and GetFinalPathNameByHandleA (ANSI)
See Also
File Management Functions
Send comments about this topic to Microsoft
Build date: 9/3/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa364962(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 11:29:48