uses Windows, SysUtils; function ToLongFilename(const Filename: String): String; var Path: String; BaseName: String; H: THandle; FD: TWin32FindData; begin { Separate to path and base name } Path := ExtractFileDir(Filename); if Path = Filename then begin Result := Filename; Exit; end; BaseName := ExtractFileName(Filename); { Convert (recursive) } Path := ToLongFilename(Path); { Search using FindFirstFile/FindClose } Result := IncludeTrailingPathDelimiter(Path) + BaseName; H := Windows.FindFirstFile(PChar(Result),FD); if H = INVALID_HANDLE_VALUE then begin Exit; end; Windows.FindClose(H); Result := IncludeTrailingPathDelimiter(Path) + FD.cFileName; end;
SFNに変換するGetShortPathNameのようにGetLongPathNameを使えばいいのかと思いきや、これではWindows NT 4.0が対象外になってしまいます。ターゲットをWindows 2000以降に限定するならいいのですけど。
0 件のコメント:
コメントを投稿