在delphi里怎么样实现关闭本身的程序,然后有启动自己呢,就象windows的重新启动一样呢?
请高手给个原代码,小弟先谢谢了

解决方案 »

  1.   

    同意 silentbug
    8过你也可以不用外部程序启动自身,方法就是用CreateRemoteThread远程注入线程到别的进程,由这个线程来启动程序
      

  2.   

    procedure TForm1.Button1Click(Sender: TObject);
    var str:string;
    begin
      str:=extractfilename(application.ExeName);
      showmessage(str);
      winexec(pchar(str),1);
      application.Terminate;end;不知道这样行不行
    小程序是 可以的
      

  3.   

    我测试了一下,请问,我的bat文件如下:
    @echo off
    %1我的程序代码如下
    procedure TForm1.Button3Click(Sender: TObject);
    begin
      if FileExists('e:\a.bat') then
      begin
        winexec(PChar('e:\a.exe '+application.ExeName),SW_HIDE);
      end;
    end;为什么不行啊?????
      

  4.   

    uses ShellAPI;
    sPath := ExtractFilePath(Application.ExeName);
      shellexecute(0, 'open', PChar(ExtractFileName(Application.ExeName)), nil, @sPath, sw_normal);
      

  5.   

    晕,winexec(PChar('e:\a.bat '+application.ExeName),SW_HIDE);
    这样可以了,呼!
      

  6.   

    ShellExecute(Handle,Nil,Pchar(Application.ExeName),nil,nil,SW_SHOWNORMAL) ;
      

  7.   

    Terminate自己,然后WinExec搞定http://lysoft.7u7.net