use xcopy  and winAPI's shellexe***()

解决方案 »

  1.   

    api函数:shfileoperation{..拷贝整个目录..}
      procedure CopyDirTree(Ahdl:THandle;SourceDir,TargetDir:String);
      var
        SHFileOpStruct:TSHFileOpStruct; FromDir,ToDir:PChar;
      begin
        GetMem(fromdir,length(sourcedir)+2);
        GetMem(todir,length(targetdir)+2);
        try
          fillchar(fromdir^,length(sourcedir)+2,0);
          fillchar(todir^,length(targetdir)+2,0);
          strcopy(fromdir,Pchar(sourcedir));
          strcopy(todir,Pchar(targetdir));      with SHFileOpStruct do
          begin
            wnd:=ahdl;
            wfunc:=FO_COPY;
            pfrom:=fromdir;
            pto:=todir;
            fflags:=FOF_NOCONFIRMATION or FOF_RENAMEONCOLLISION;
            fAnyOperationsAborted:=false;
            hnamemappings:=nil;
            lpszprogresstitle:=nil;
            if shfileoperation(shfileopstruct)<>0 then
              raiselastwin32error;
          end;
        finally
          FreeMem(fromdir,length(sourcedir)+2);
          FreeMem(todir,length(targetdir)+2);
        end;
      end;