如当前运行的程序叫AP1.exe,若想让用户点击某个按钮后,自动关闭当前程序,然后再重新激活AP1.exe

解决方案 »

  1.   

    OncloseWinexec(PChar(Appliction.Exename), SW_SHOW);
      

  2.   

    uses ShellAPI;
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      close;
      ShellExecute(handle,nil,'api.exe',nil,nil,SW_Normal);
    end;
      

  3.   

    procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
    begin
      WinExec(PChar(Application.Exename), SW_SHOW);
    end;
      

  4.   

    补充说明一下,不能在Onclose事件里写,因为每次关闭的时候就重执行,永远也结束不了,成了死循环
      

  5.   

    在退出里啊用户选择退出命令时执行如果单击按钮就不执行了
    WinExec(PChar(Application.ExeName),SW_SHOWNORMAL);