unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> Edit1: TEdit;<br> Edit2: TEdit;<br> Edit3: TEdit;<br> procedure Button1Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br><br>uses ShellAPI;<br><br>procedure CopyDirectoryTree(AHandle: THandle; Src, Dest: String);<br>var<br> SHFileOpStruct: TSHFileOpStruct;<br> FromDir: PChar;<br> ToDir: PChar;<br>begin<br> GetMem(FromDir, Length(Src) + 2);<br> try<br> GetMem(ToDir, Length(Dest) + 2);<br> try<br> FillChar(FromDir^, Length(Src) + 2, 0);<br> FillChar(ToDir^, Length(Dest) + 2, 0);<br> StrCopy(FromDir, PChar(Src));<br> StrCopy(ToDir, PChar(Dest));<br> with SHFileOpStruct do<br> begin<br> Wnd := AHandle; // Assign the window handle<br> wFunc := FO_COPY; // Specify a file copy<br> pFrom := FromDir;<br> pTo := ToDir;<br> fFlags := FOF_NOCONFIRMATION or FOF_RENAMEONCOLLISION;<br> fAnyOperationsAborted := False;<br> hNameMappings := nil;<br> lpszProgressTitle := nil;<br> if SHFileOperation(SHFileOpStruct) <> 0 then<br> RaiseLastWin32Error;<br> end;<br> finally<br> FreeMem(ToDir, Length(Dest) + 2);<br> end;<br> finally<br> FreeMem(FromDir, Length(Src) + 2);<br> end;<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br> CopyDirectoryTree(Handle, Edit1.Text, Edit2.Text);<br> CopyDirectoryTree(Handle, Edit1.Text, Edit3.Text);<br>end;<br><br>end.<br>