Mega Code Archive

 
Categories / Delphi / API
 

Getting the longfilename from a file

Question: How do I get the long file name of a file or directory from the short file name? Answer: You can use the Win32_Find_Data member of TSearchRec to extract this information. Example: procedure TForm1.Button1Click(Sender: TObject); var SearchRec : TSearchRec; Success : integer; begin Success := SysUtils.FindFirst('C:\DownLoad\dial-u~1.htm', faAnyFile, SearchRec); if Success = 0 then begin ShowMessage(SearchRec.FindData.CFileName); end; SysUtils.FindClose(SearchRec); end;