exe所在路径

procedure TForm1.btn1Click(Sender: TObject);
begin
  //完整路径  E:\UsrSoft\Desktop\FileNameDemo\Project1.exe
  edt1.Text := paramstr(0);
  edt1.Text := Application.ExeName; //同上

  //文件路径  E:\UsrSoft\Desktop\FileNameDemo\
  edt2.Text := ExtractFilePath(Application.ExeName);

  //文件所在文件夹  E:\UsrSoft\Desktop\FileNameDemo
  edt6.Text := ExtractFileDir(Application.ExeName);

  //文件名.扩展名  Project1.exe
  edt3.Text := ExtractFileName(Application.ExeName);

  //.扩展名  .exe
  edt4.Text := ExtractFileExt(Application.ExeName);

  //去掉扩展名
  edt5.Text := ChangeFileExt(ExtractFileName(Application.ExeName), ''); //  Project1
  edt7.Text := ChangeFileExt(Application.ExeName, ''); //  E:\UsrSoft\Desktop\FileNameDemo\Project1

  //更改扩展名  E:\UsrSoft\Desktop\FileNameDemo\Project1.zip
  edt8.Text := ChangeFileExt(Application.ExeName, '.zip');

  //更改文件名  E:\UsrSoft\Desktop\FileNameDemo\Project1_20150225154703.exe
  edt9.Text := ChangeFileExt(Application.ExeName, '') +
    '_' + FormatDateTime('yyyymmddhhmmss', Now) +
    ExtractFileExt(Application.ExeName);
end;

posted @ 2018-09-30 12:30  zzmiot  阅读(635)  评论(0编辑  收藏  举报