void __fastcall DeleOldExe()
{
AnsiString strTmp;
AnsiString strBatFileName = "tmp.bat";
TFileStream *pFS = new TFileStream(strBatFileName,fmCreate );
try
{
strTmp = "del " + ExtractFileName(Application->ExeName) + "\n";//删除主程序
pFS->Write(strTmp.c_str(),strTmp.Length());
strTmp = "del %0\n";//删除批处理命令本身
pFS->Write(strTmp.c_str(),strTmp.Length());
}
__finally
{
delete pFS;
WinExec(strBatFileName.c_str(), SW_HIDE);//后台偷偷运行批处理
}
}