我在Delphi XE8 64位
中编译以下代码(COM对象)function TUtility.GetDLLPath: WideString;
var
Buffer: array [0 .. C_MAX_PATH_LEN] of char;
begin
GetModuleFileName(hInstance, Buffer, Length(Buffer));
Result := Buffer;
end;
我得到以下路径字符串(在VBScript中调用)
C:\PROGRA~2\XYZ\AAABBB~1\64\Tools.dll
如何获得长路径而不是短路径?
答案 0 :(得分:5)
致电GetLongPathName
:
function LongPathName(const ShortPathName: string): string;
var
Retval: DWORD;
Buff: array [0..MAX_PATH-1] of Char;
begin
Retval := GetLongPathName(PChar(ShortPathName), Buff, Length(Buff));
Win32Check(Retval <> 0);
Result := Buff;
end;