我用的是SHFileOperation,部分代码如下:
begin
strSourFilePath:='f:\source';
DeFieldpath:='f:\destination';
FillChar(FromBuf,Sizeof(FromBuf),0);
FillChar(ToBuf,Sizeof(ToBuf),0);
StrPCopy(FromBuf,Pchar(strSourFilePath));
StrPCopy(ToBuf,Pchar(DeFieldpath));
with OpStruc do
begin
wFunc:=FO_COPY;
pFrom:=@FromBuf;
pTo:=@ToBuf;
fFlags:=FOF_NOCONFIRMATION or FOF_MULTIDESTFILES or FOF_SIMPLEPROGRESS;// or FOF_RENAMEONCOLLISION;
fAnyOperationsAborted:=False;
hNameMappings:=nil;
lpszProgressTitle:=nil;
end;
if SHFileOperation(OpStruc)=0 then
begin
showmessage('文件拷贝成功');
end else
begin
showmessage('文件拷贝失败');
end;
end;
我想问一下加入一个进度条TProgressBar,怎样实现显示进度
begin
strSourFilePath:='f:\source';
DeFieldpath:='f:\destination';
FillChar(FromBuf,Sizeof(FromBuf),0);
FillChar(ToBuf,Sizeof(ToBuf),0);
StrPCopy(FromBuf,Pchar(strSourFilePath));
StrPCopy(ToBuf,Pchar(DeFieldpath));
with OpStruc do
begin
wFunc:=FO_COPY;
pFrom:=@FromBuf;
pTo:=@ToBuf;
fFlags:=FOF_NOCONFIRMATION or FOF_MULTIDESTFILES or FOF_SIMPLEPROGRESS;// or FOF_RENAMEONCOLLISION;
fAnyOperationsAborted:=False;
hNameMappings:=nil;
lpszProgressTitle:=nil;
end;
if SHFileOperation(OpStruc)=0 then
begin
showmessage('文件拷贝成功');
end else
begin
showmessage('文件拷贝失败');
end;
end;
我想问一下加入一个进度条TProgressBar,怎样实现显示进度
var
i:integer;
begin
ProgressBar1.Min:=0;
ProgressBar1.Max:=10000;
ProgressBar1.Step:=1;
for i:=1 to 10000 do
begin
ProgressBar1.StepIt;
end;
如下试试:
var
i:integer;
n:integer;
begin
...
ProgressBar1.Min:=0; ProgressBar1.Max:=n;
ProgressBar1.Step:=1;
for i:=1 to n do
....
end;
传给值给n,比如:文件的个数或...