procedure TMainForm.IdFTP1Work(Sender: TObject;
AWorkMode: TWorkMode;
const AWorkCount: Integer);
Var
S: String;
TotalTime: TDateTime;
H, M, Sec, MS: Word;
DLTime: do
uble;
begin
TotalTime := Now - STime;
DecodeTime(TotalTime, H, M, Sec, MS);
Sec := Sec + M * 60 + H * 3600;
DLTime := Sec + MS / 1000;
if DLTime > 0 then
AverageSpeed := (AWorkCount / 1024) / DLTime;
if AverageSpeed > 0 then
begin
Sec := Trunc(((ProgressBar1.Max - AWorkCount) / 1024) / AverageSpeed);
S := Format('%2d:%2d:%2d', [Sec div 3600, (Sec div 60) mod 60, Sec mod 60]);
S := '剩余时间: ' + S;
end
else
S := '';
S := FormatFloat('0.00 KB/s', AverageSpeed) + ';
' + S;
case AWorkMode of
wmRead: StatusBar1.Panels[1].Text := '下载速度:' + S;
wmWrite: StatusBar1.Panels[1].Text := '上传速度:' + S;
end;
if AbortTransfer then
IdFTP1.Abort;
ProgressBar1.Position := AWorkCount;
AbortTransfer := false;
end;
/////////////关键代码如上