我的下面一段代码是经过测试的,可以连子目录拷贝:<br>var<br> OpStruc: TSHFileOpStruct;<br> FromBuf, ToBuf: Array [0..128] of Char;<br>begin<br> FillChar( FromBuf, Sizeof(FromBuf), 0 );<br> FillChar( ToBuf, Sizeof(ToBuf), 0 );<br> StrPCopy( FromBuf, Pchar(Edit1.Text) ); //edit1的内容是源目录<br> StrPCopy( ToBuf, Pchar(Edit2.Text) ); //edit2是目的目录<br> // 设置OpStruc<br> with OpStruc do<br> begin<br> Wnd:= Handle;<br> wFunc:= FO_COPY;<br> pFrom:= @FromBuf;<br> pTo := @ToBuf ;<br> fFlags:=FOF_NOCONFIRMATION or FOF_RENAMEONCOLLISION;<br> fAnyOperationsAborted:= False;<br> hNameMappings:= nil;<br> lpszProgressTitle:=nil;<br> end;<br> if SHFileOperation( OpStruc ) = 0 then //复制成功返回值为0<br> MessageBox(Handle,'复制完毕。' , '信息' ,Mb_Ok+Mb_IconInformation);<br>end;<br>