网站首页  词典首页

请输入您要查询的函数:

 

术语 getshortpathname
释义 GetShortPathName
语法:
C++
DWORD WINAPI GetShortPathName(
__in LPCTSTR lpszLongPath,
__out LPTSTR lpszShortPath,
__in DWORD cchBuffer
);
GetShortPathName函数
检索指定的路径短路径的形式。
有关文件和路径名信息,请参阅文件名,路径和命名空间。
参数
lpszLongPath [in]
路径字符串。
在此函数的ANSI版本,名称被限制为MAX_PATH字符。为了延长此限制,以32,767宽字符,调用的功能和前面加上“\\ Unicode版本\\?\\”的路径。有关更多信息,请参见命名一个文件。
lpszShortPath [out]
一个缓冲区指针收到NULL结尾的路径lpszLongPath指定的简称。
Passing NULL for this parameter and zero for cchBuffer will always return the required buffer size for a specified lpszLongPath.
cchBuffer [in]
缓冲区大小lpszShortPath点,在TCHARs。
将此参数设置为0,如果lpszShortPath设置为NULL。
返回值
如果函数成功,返回值是长度,TCHARs,认为被复制到lpszShortPath字符串,不包括终止空字符。
如果lpszShortPath缓冲区太小包含的路径,返回值是缓冲区的大小,在TCHARs,这是必须持有的路径和终止空字符。
如果该函数的任何其他原因而失败,返回值是零。为了获得更多错误信息,调用GetLastError。
备注
在指定路径lpszLongPath没有成为一个完整的或长期的道路。简短的形式可以大于指定的路径。
如果返回值是比cchBuffer指定的值大,您可以再次调用该函数的缓冲区足够大,以保存路径。有关此除了使用零长度为动态分配缓冲区的案例,请参阅示例代码部分。
注意:尽管在这种情况下返回值是一个长度,其中包括终止空字符,就成功返回值不包括终止在伯爵空字符。
如果指定的路径已在其短暂的形式和转换是不需要的,功能简单复制指定的路径由lpszShortPath指定的缓冲区。
您可以设置lpszShortPath作为lpszLongPath为相同的值,也就是说,您可以设置短路径的路径字符串的地址输入输出缓冲区。始终确保cchBuffer准确地反映总规模,在TCHARs,此缓冲区。
您可以通过调用功能的GetLongPathName从短期文件的名称长名称。此外,如果GetLongPathName不可用,您可以调用的每个路径组件FindFirstFile得到相应的长名称。
实例
举一个例子,它使用GetShortPathName,看到GetFullPathName示例代码部分。
下面的C + +示例演示如何使用动态分配的输出缓冲区。
//...
long length = 0;
TCHAR* buffer = NULL;
// First obtain the size needed by passing NULL and 0.
length = GetShortPathName(lpszPath, NULL, 0);
if (length == 0) ErrorExit(TEXT("GetShortPathName"));
// Dynamically allocate the correct size
// (terminating null char was included in length)
buffer = new TCHAR[length];
// Now simply call again using same long path.
length = GetShortPathName(lpszPath, buffer, length);
if (length == 0) ErrorExit(TEXT("GetShortPathName"));
_tprintf(TEXT("long name = %s shortname = %s"), lpszPath, buffer);

delete [] buffer;
///...

要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinBase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode和ANSI namesGetShortPathNameW(Unicode)和GetShortPathNameA(ANSI)的
参见
文件管理函数
FindFirstFile
GetFullPathName
GetLongPathName
SetFileShortName
文件名,路径和名称空间
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年9月3日
==英文原文==GetShortPathName Function
Retrieves the short path form of the specified path.
For more information about file and path names, see File Names, Paths, and Namespaces .
Syntax
C++
DWORD WINAPI GetShortPathName(
__in LPCTSTR lpszLongPath,
__out LPTSTR lpszShortPath,
__in DWORD cchBuffer
);
Parameters
lpszLongPath [in]
The path string.
In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\\\?\\" to the path. For more information, see Naming a File .
lpszShortPath [out]
A pointer to a buffer to receive the null-terminated short form of the path that lpszLongPath specifies.
Passing NULL for this parameter and zero for cchBuffer will always return the required buffer size for a specified lpszLongPath.
cchBuffer [in]
The size of the buffer that lpszShortPath points to, in TCHARs.
Set this parameter to zero if lpszShortPath is set to NULL.
Return Value
If the function succeeds, the return value is the length, in TCHARs, of the string that is copied to lpszShortPath, not including the terminating null character.
If the lpszShortPath buffer is too small to contain the path, the return value is the size of the buffer, in TCHARs, that is required to hold the path and the terminating null character.
If the function fails for any other reason, the return value is zero. To get extended error information, call GetLastError .
Remarks
The path that lpszLongPath specifies does not have to be a full or long path. The short form can be longer than the specified path.
If the return value is greater than the value specified in cchBuffer, you can call the function again with a buffer that is large enough to hold the path. For an example of this case in addition to using zero-length buffer for dynamic allocation, see the Example Code section.
Note Although the return value in this case is a length that includes the terminating null character, the return value on success does not include the terminating null character in the count.
If the specified path is already in its short form and conversion is not needed, the function simply copies the specified path to the buffer specified by lpszShortPath.
You can set lpszShortPath to the same value as lpszLongPath; in other words, you can set the output buffer for the short path to the address of the input path string. Always ensure cchBuffer accurately represents the total size, in TCHARs, of this buffer.
You can obtain the long name of a file from the short name by calling the GetLongPathName function. Alternatively, where GetLongPathName is not available, you can call FindFirstFile on each component of the path to get the corresponding long name.
Examples
For an example that uses GetShortPathName, see the Example Code section for GetFullPathName .
The following C++ example shows how to use a dynamically allocated output buffer.
//...
long length = 0;
TCHAR* buffer = NULL;
// First obtain the size needed by passing NULL and 0.
length = GetShortPathName(lpszPath, NULL, 0);
if (length == 0) ErrorExit(TEXT("GetShortPathName"));
// Dynamically allocate the correct size
// (terminating null char was included in length)
buffer = new TCHAR[length];
// Now simply call again using same long path.
length = GetShortPathName(lpszPath, buffer, length);
if (length == 0) ErrorExit(TEXT("GetShortPathName"));
_tprintf(TEXT("long name = %s shortname = %s"), lpszPath, buffer);

delete [] buffer;
///...
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinBase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode and ANSI namesGetShortPathNameW (Unicode) and GetShortPathNameA (ANSI)
See Also
File Management Functions
FindFirstFile
GetFullPathName
GetLongPathName
SetFileShortName
File Names, Paths, and Namespaces
Send comments about this topic to Microsoft
Build date: 9/3/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa364989(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:26:14