Source Code



How to convert Short to Long filenames

  • anonymous
  • Dec 20' 13
  • Delphi
  • 231
  • 123
  • United States

The Source Code

 


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;

 

Usage :


procedure TForm1.Button1Click(Sender: TObject);
begin
  Caption := GetLongFileName(''C:\Program Files\Delphi6\Lib\BK_STR~1.DPK'');
  // -- BK_StringGrid.dpk
end;

 

NOTE :

// For  Delphi 4 you can use the ExpandFileName() function
// ExpandFileName converts the relative file name into a fully qualified path name.

ad

a

  • Tags : delphi, longname, path, convert
comments powered by Disqus

Related Code

Get Database Path With Alias

SQL data to Excel

Execute a JavaScript Code on a TWebBrowser Document

Save a StringGrid as a CSV file

Empty Recylce Bin

Get MAC Address of Network Card

Kill Active Program

Resizable forms and size grip

Simple Like Function

Suspend the PC



Category