求助!大侠们。delphi如何让程序关闭后又打开自己?类似于注销的效果。

解决方案 »

  1.   

    delphi程序关闭前运行一个bat,bat又打开delphi程序
      

  2.   

    Procedure openYourSelf;
    begin
       Application.Terminate; //close yourself first.
       ShellExecute(Handle,'Open',Pchar(Application.ExeName),nil,nil,SW_SHOWNORMAL); //open your self again.
    end;
      

  3.   

    我来帮你!用个bat就行了
    procedure KillSelf;
    var
      f: textfile;
      FullName,sShortFileName: string;
    begin
      FullName:=application.ExeName;
      sShortFileName := Copy(FullName,length(ExtractFilePath(FullName))+1,Length(FullName));
      assignfile(f, '.\delme.bat');
      rewrite(f);
      writeln(f, '@echo off');
      writeln(f, ':loop');
      writeln(f, 'del "' + FullName+'"');
      writeln(f, 'if exist "' + FullName + '" goto loop');
      writeln(f, 'copy "' + ExtractFilePath(FullName) + 'Temp\'+sShortFileName+'" "'+FullName+'"');
      writeln(f, 'del "' + ExtractFilePath(FullName) + 'Temp\'+sShortFileName+'"');
      writeln(f, 'start "" "' + FullName+'"');
      //writeln(f, 'del "' + ExtractFilePath(FullName) + ctZipName+'"');
      writeln(f, ' del .\delme.bat');
      closefile(f);
      winexec('.\delme.bat', SW_HIDE);
    end;