Function Copy_Dir(SourceDir,DestDir:String;nLx:Integer):Boolean; Var Opstruc: TshFileOpStruct; frombuf,tobuf: Array[0..128] of Char; begin FillChar(frombuf,Sizeof(frombuf),0); FillChar(tobuf,Sizeof(tobuf),0); StrPcopy(frombuf,SourceDir); Case nLx of 1: StrPcopy(tobuf,DestDir); end; With Opstruc Do Begin Wnd:=0; Case nLx of 1: wFunc:=FO_COPY; 2: wFunc:=FO_DELETE; Else wFunc:=FO_COPY; end; pFrom:=@frombuf; pTo:=@tobuf; fFlags:=FOF_NOCONFIRMATION; fAnyOperationsAborted:=False; hNameMappings:=Nil; lpszProgressTitle:=Nil; end; try ShFileOperation(OpStruc); Result:=True; except Result:=False; end; end;
Function Copy_Dir(SourceDir,DestDir:String;nLx:Integer):Boolean; Var Opstruc: TshFileOpStruct; frombuf,tobuf: Array[0..128] of Char; begin FillChar(frombuf,Sizeof(frombuf),0); FillChar(tobuf,Sizeof(tobuf),0); StrPcopy(frombuf,SourceDir); Case nLx of 1: StrPcopy(tobuf,DestDir); end; With Opstruc Do Begin Wnd:=0; Case nLx of 1: wFunc:=FO_COPY; 2: wFunc:=FO_DELETE; Else wFunc:=FO_COPY; end; pFrom:=@frombuf; pTo:=@tobuf; fFlags:=FOF_NOCONFIRMATION; fAnyOperationsAborted:=False; hNameMappings:=Nil; lpszProgressTitle:=Nil; end; try ShFileOperation(OpStruc); Result:=True; except Result:=False; end; end;
Var
Opstruc: TshFileOpStruct;
frombuf,tobuf: Array[0..128] of Char;
begin
FillChar(frombuf,Sizeof(frombuf),0);
FillChar(tobuf,Sizeof(tobuf),0);
StrPcopy(frombuf,SourceDir);
Case nLx of
1:
StrPcopy(tobuf,DestDir);
end;
With Opstruc Do
Begin
Wnd:=0;
Case nLx of
1: wFunc:=FO_COPY;
2: wFunc:=FO_DELETE;
Else wFunc:=FO_COPY;
end;
pFrom:=@frombuf;
pTo:=@tobuf;
fFlags:=FOF_NOCONFIRMATION;
fAnyOperationsAborted:=False;
hNameMappings:=Nil;
lpszProgressTitle:=Nil;
end;
try
ShFileOperation(OpStruc);
Result:=True;
except
Result:=False;
end;
end;
Var
Opstruc: TshFileOpStruct;
frombuf,tobuf: Array[0..128] of Char;
begin
FillChar(frombuf,Sizeof(frombuf),0);
FillChar(tobuf,Sizeof(tobuf),0);
StrPcopy(frombuf,SourceDir);
Case nLx of
1:
StrPcopy(tobuf,DestDir);
end;
With Opstruc Do
Begin
Wnd:=0;
Case nLx of
1: wFunc:=FO_COPY;
2: wFunc:=FO_DELETE;
Else wFunc:=FO_COPY;
end;
pFrom:=@frombuf;
pTo:=@tobuf;
fFlags:=FOF_NOCONFIRMATION;
fAnyOperationsAborted:=False;
hNameMappings:=Nil;
lpszProgressTitle:=Nil;
end;
try
ShFileOperation(OpStruc);
Result:=True;
except
Result:=False;
end;
end;
shellapi;
///////
Copy_Dir('c:\aa','d:\',1 );
1: wFunc:=FO_COPY;//拷贝
2: wFunc:=FO_DELETE;//删除
Else wFunc:=FO_COPY;
end;