请问如何吧C:\DOCUME~1\转换成完整路径?
例如C:\DOCUME~1\应当转换成C:\Documents and Settings\
应该有哪个WIN API可以实现.请各位高手给小弟个小例子.或者知道哪个API也可以.谢谢
例如C:\DOCUME~1\应当转换成C:\Documents and Settings\
应该有哪个WIN API可以实现.请各位高手给小弟个小例子.或者知道哪个API也可以.谢谢
解决方案 »
- delphi webbrowser求助大虾
- 怎么将内存地址转化为Integer类型?
- 大家好,主细表结构的数据怎么插入?
- 如何使DateTimePicker显示系统时间啊!!
- 各位大哥给解释一条语句~~在线等待,明白了就给分
- 高分求教,关于SetWindowsHookEx的问题,救急!
- 在delphi中如何将array类型转化为string类型
- 我的程序是给予基于事件驱动的
- 有研究过IManipulationProcessor和FInertiaProcessor这个方面的吗?
- 如何实现订单号由日期加三位数字组成
- 大侠快救命!帮帮小第!treeview建树问题!
- 请问super.paint();语句是什么意思?
DWORD nBufferLength, // size, in characters, of path buffer
LPTSTR lpBuffer, // address of path buffer
LPTSTR *lpFilePart // address of filename in path
);
ParameterslpFileNamePoints to a null-terminated string that specifies a valid filename. This string can use either short (the 8.3 form) or long filenames.nBufferLengthSpecifies the size, in characters, of the buffer for the drive and path. lpBufferPoints to a buffer that contains the null-terminated string for the name of the drive and path. lpFilePartPoints to a variable that receives the address (in lpBuffer) of the final filename component in the path. This filename component is the long filename, if any, rather than the 8.3 form of the filename. Return ValuesIf the GetFullPathName function succeeds, the return value is the length, in characters, of the string copied to lpBuffer, not including the terminating null character.
If the lpBuffer buffer is too small, the return value is the size of the buffer, in characters, required to hold the path.
If the function fails, the return value is zero. To get extended error information, call GetLastError. ResThe GetFullPathName function merges the name of the current drive and directory with the specified filename to determine the full path and filename of the specified file. It also calculates the address of the filename portion of the full path and filename. This function does not verify that the resulting path and filename are valid or that they refer to an existing file on the associated volume.
var
Desktop: IShellFolder;
pIDList: PITEMIDLIST;
NameS: String;
NameW: WideString;
Len : integer;
Buffer: array[0..MAX_PATH] of Char;
pDummy: PCHAR;
pchEaten, Attributes: ULONG;
begin
pIDList := Nil;
Len := GetFullPathName(PChar(ShortName), 0, PChar(result), pDummy);
SetLength(NameS, Len);
GetFullPathName(PChar(ShortName), Len, PChar(NameS), pDummy);
NameW := NameS;
OleCheck(SHGetDesktopFolder(Desktop));
OleCheck(Desktop.ParseDisplayName(0, Nil, PWideChar(NameW), pchEaten, pIDList, Attributes));
if not SHGetPathFromIDList(pIDList, Buffer) then
raise EConvertError.Create('error');
Result := StrPas(Buffer);
end;
ShellAPI;
...
function GetLongFileName(const FileName: string): string;
var
SHFileInfo: TSHFileInfo;
begin
if SHGetFileInfo(PChar(FileName),
0,
SHFileInfo,
SizeOf(SHFileInfo),
SHGFI_DISPLAYNAME) <> 0 then
Result := string(SHFileInfo.szDisplayName)
else
Result := FileName;
end;
void __fastcall TForm1::Button5Click(TObject *Sender)
{
static char strLongName[MAX_PATH+4];
GetLongPathName ( "C:\Progra~1", strLongName, MAX_PATH );
ShowMessage ( strLongName );
}
我现在没有安装 Delphi,回家帮你看看
看看 MSDN 中的帮助
GetLongPathName
[This is preliminary documentation and subject to change.] The GetLongPathName function converts the specified path to its long form. If no long path is found, this function simply returns the specified name. DWORD GetLongPathName(
LPCTSTR lpszShortPath,
LPTSTR lpszLongPath,
DWORD cchBuffer
);
Parameters
lpszShortPath
Pointer to a null-terminated path to be converted.
lpszLongPath
Pointer to the buffer to receive the long path. You can use the same buffer you used for the lpszShortPath parameter.
cchBuffer
Specifies the size of the buffer, in characters.
Return Values
If the function succeeds, the return value is the length of the string copied to the lpszLongPath parameter, in characters. This length does not include the terminating null character.If lpszLongPath is too small, the function returns the size of the buffer required to hold the long path, in characters.If the function fails, the return value is zero. To get extended error information, call GetLastError.QuickInfo
Windows NT: Requires version 5.0 or later.
Windows: Requires Windows 98 or later.
Windows CE: Unsupported.
Header: Declared in winbase.h.
Import Library: Use kernel32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT.See Also
File I/O Overview, File Functions, GetShortPathName