一个程序,发生异常了,退出,我想让它自己重新启动,如何实现??急急,在线等候

解决方案 »

  1.   

    呵呵
    用第三方的组件EurekaLog Enterprise可以实现你的功能的
    http://www.delphibox.com/article.asp?articleid=1222
      

  2.   

    主和序aaa.exe发生异常有时会提示要重启,打开检测程序bbb.exebbb.exe 在打开时执行以下代码。    procedure WinExecCalc;
    var
      Wnd: HWND;
      lRet: Integer;
    begin
      Wnd := FindWindow('主和序', '主和序名');
      if Wnd > 0 then
      begin
        将主程序关闭    //再打开主程序
        lRet := WinExec('aaa.exe', SW_SHOWNORMAL);
        if lRet < 31 then
          ErrorBox('打开出错。');
      end;  end
      else
      begin
        lRet := WinExec('aaa.exe', SW_SHOWNORMAL);
        if lRet < 31 then
          ErrorBox('打开出错。');
      end;
    end;
      

  3.   

    挂钩Application的OnException事件,在这个事件的处理程序里面,加上
    WinExec(PChar(Application.ExeName), SW_SHOW);
    即可