(计算机世界报上的文章)
---- 以delphi为例,在form关闭的时候执行以下函数closeme即可:
procedure TForm1.closeme;
var f:textfile;
begin
assignfile(f,'./delme.bat');
rewrite(f);
writeln(f,'@echo off');
writeln(f,':loop');
writeln(f,'del "'+application.ExeName+'"');
writeln(f,'if exist ./file.exe goto loop');
writeln(f,'del ./delme.bat');
closefile(f);
winexec('./delme.bat', SW_HIDE);
close;
end;