Mega Code Archive

 
Categories / Delphi / Files
 

Convert Short to Long filenames

Title: convert Short to Long filenames? uses 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; // Example: procedure TForm1.Button1Click(Sender: TObject); begin Caption := GetLongFileName('C:\Program Files\Delphi6\Lib\BK_STR~1.DPK'); // -- BK_StringGrid.dpk end; // For Delphi 4 you can use the ExpandFileName() function // ExpandFileName converts the relative file name into a fully qualified path name.