⤷ Convert long filename to DOS filename

Use API function GetShortPathName:

procedure TForm1.Button1Click(Sender: TObject);
var
  FileName: string;
  ATmp: array[0..255] of Char;
begin
  FileName:=FileListBox1.FileName;
  Label1.Caption:=FileName;
  if GetShortPathName(PChar(FileName),ATmp,SizeOf(ATmp)-1)=0 then
    Label2.Caption:=FileName
  else
    Label2.Caption:=StrPas(ATmp);
end;
More for developers