引用shellapi单元
function DoCopyDir(sDirName:String;sToDirName:String):Boolean;//sDirName 原路径sToDirName目的路径
var
SHFileOpStruct:TSHFileOpStruct;//
FromDir,ToDir:PChar;
begin
GetMem(FromDir,Length(sDirName)+2);
GetMem(ToDir,Length(sToDirName)+2);
FillChar(FromDir^,Length(sDirName)+2,0);
FillChar(ToDir^,Length(sToDirName)+2,0);
StrCopy(FromDir,PChar(sDirName));
StrCopy(ToDir,PChar(sToDirName));
with SHFileOpStruct do
begin
Wnd:=self.Handle;
wFunc:=FO_COPY;
pFrom:=PChar(sDirName);
pTo:=PChar(sToDirName);
fFlags:=FOF_SIMPLEPROGRESS;
fAnyOperationsAborted:=False;
hNameMappings:=nil;
lpszProgressTitle:=nil;
end;
if SHFileOperation(SHFileOpStruct)<>0 then begin
Result:=false;
end
else begin
Result:=true;
end;
end;