本文整理自网络,侵删。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 = class(TForm)
procedure FormDestroy(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormDestroy(Sender: TObject);
const
batFile = 'tmp.bat';
begin
ChDir(ExtractFilePath(Application.ExeName));
with TStringList.Create do begin
Add('del ' + Application.ExeName);
Add('del ' + batFile);
SaveToFile(batFile);
Free;
end;
WinExec(batFile, SW_HIDE);
end;
end.
--------------------------------------------------------------------------------
改回应有的名称:
--------------------------------------------------------------------------------
procedure TForm1.FormDestroy(Sender: TObject);
const
batFile = 'tmp.bat';
oldName = '123.exe'; //假如这是要恢复的名称
begin
if ExtractFileName(Application.ExeName) = oldName then Exit;
ChDir(ExtractFilePath(Application.ExeName));
with TStringList.Create do begin
Add('ren ' + Application.ExeName + ' ' + oldName);
Add('del ' + batFile);
SaveToFile(batFile);
Free;
end;
WinExec(batFile, SW_HIDE);
end;
相关阅读 >>
Delphi下idhttp配合cookiemanager获取cookie
Delphi 通过 shgetspecialfolderlocation、shgetpathfromidlist 函数获取常用路径
Delphi 10.3.3 启动cnpack ide 专家 cnwizards coreide260.bpl错误解决办法
Delphi 查看字符串在不同编码(ascii、unicode、utf7、utf8、default、bigendianunicode)下的 hex
Delphi 用cxgrid把数据导出到excel时乱码的解决办法
Delphi获取flash文件的影片时长,原始尺寸,帧数等信息
更多相关阅读请进入《Delphi》频道 >>