当前位置: 网站首页 > 开发语言 > DELPHI

显示copy文件时的进度条

时间:1970-1-1 08:33:31来源: DELPHI作者:admin 点击:5次 字体 [ С]

function CopyProgress(
TotalFileSize         : LARGE_INTEGER; // total file size, in bytes
TotalBytesTransferred : LARGE_INTEGER; // total number of bytes transferred
StreamSize            : LARGE_INTEGER; // total number of bytes for this stream
StreamBytesTransferred: LARGE_INTEGER; // total number of bytes transferred for this stream
dwStreamNumber        : DWORD;          // the current stream
dwCallbackReason      : DWORD;          // reason for callback
hSourceFile           : THANDLE;        // handle to the source file
hDestinationFile      : THANDLE;        // handle to the destination file
lpData                : Pointer         // passed by CopyFileEx
) : DWORD; stdcall;
begin
Form1.ProgressBar1.Position := Form1.ProgressBar1.Position+1;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
Cancel    : Bool;
Src, Dest : String;
hf : HFile;
ofs : OFSTRUCT;
size : Cardinal;
begin
Cancel := False;
Src := 'j:\[大富翁论坛离线资料].DelphiBBSchm.rar';
Dest:= 'e:.rar';
hf := OpenFile(PChar(src), ofs, 0);
size := GetFileSize(hf, nil);
self.ProgressBar1.Max := (size shr 16)+2;
self.ProgressBar1.Position := 0;

发表评论
验证码:
最新评论