求多线程复制代码
1、要能复制大文件(1G左右)
2、要有复制进度
-----------------------------
下面的代码看看,复制大于10M左右的文件就不行了
程序忙得要死!
--------------------------
procedure TForm1.Copy_File(Source:string ;Destination:string);
var
FromF,ToF: file ;
Buffer : array[0..4096] of char;
NumRead : integer;
FileLength : longint;
begin
AssignFile(FromF,Source);
reset(FromF,1);
AssignFile(ToF,Destination);
rewrite(ToF,1);
FileLength:=FileSize(FromF);
With Form1.ProgressBar1 do
begin
Min := 0;
Max := FileLength;
while FileLength > 0 do
begin
BlockRead(FromF,Buffer[0],SizeOf(Buffer),NumRead);
FileLength := FileLength - NumRead;
BlockWrite(ToF,Buffer[0],NumRead);
Position := Position + NumRead;
end;
CloseFile(FromF);
CloseFile(ToF);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
copy_file('C:\111\System.dat','C:\222\System.dat' );
end;

解决方案 »

  1.   

    Performs a copy, move, rename, or delete operation on a file system object. WINSHELLAPI int WINAPI SHFileOperation(    LPSHFILEOPSTRUCT lpFileOp
       );
     ParameterslpFileOpPointer to an SHFILEOPSTRUCT structure that contains information the function needs to carry out the operation. Return ValuesReturns zero if successful or nonzero if an error occurs. See AlsoSHFILEOPSTRUCT
      

  2.   

    To outer2000(天外流星) :
    你说什么,偶不懂 ~#_#~
      

  3.   

    这是个API,有进度条,进行文件的复制,移动等;
      

  4.   

    To outer2000(天外流星) :
    是不是:
    var
      shfos: SHFILEOPSTRUCT;
      sFrom, sTo: string;
    begin
      sFrom := 'c:\test\*.*';
      sTo := 'd:\test\';
      with shfos do begin
        shfos.Wnd := Handle;
        wFunc := FO_COPY;
        shfos.pFrom := PChar(sFrom + #0);
        shfos.pTo := PChar(sTo + #0);
        fAnyOperationsAborted := True;
        shfos.fFlags := FOF_ALLOWUNDO;
      end;
      SHFileOperation(shfos);
    end;
    不是多线程呀
      

  5.   

    你自己在程序里createthread新建一个线程进行操作不就行了阿,将线程函数设置为你的拷贝函数.
    你是想要文件复制的"算法"还是想问如何用createthread建立和执行线程?