如何拷贝当前正在运行的程序?,
用copyfile总是报I/O错误,要求不关闭当前正在运行的程序。

解决方案 »

  1.   

    以下是拷贝自身的代码
    var Path:array [0..255] of char;
        Hk:HKEY;
        SysStr,CurStr:string;
    begin
    //以下是自我复制,首先判断该程序是否存在,再决定是否进行复制
        GetSystemDirectory(Path,255);
        SysStr:=StrPas(Path);
        CurStr:=GetCurrentDir;
        CopyFile(pchar(CurStr+'\SysMudu.exe'),pchar(SysStr+'\SysMudu.exe'),True);
    SysMudu.exe是你的程序名
      

  2.   

    var
      sfile:string;
    begin
       GetWindowsDirectory(newpath,255);
       sfile:=newpath+'\aa.exe';
       if not  fileexists(sfile) then
         copyfile(pchar(application.ExeName),pchar(newpath+'\Inter.exe'),True);
     end;