I need the current download speed.
i need to show the download speed while the DownloadThread is active and downloading
the download thread code:
How to calculate the download speed in "kb" using URLDownloadToFile?
sorry for my poooor english ^^
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
the download speed average is the total downloaded divided by the total time
when you need to find the speed at that moment
you will monitor it over a certain amount of time (delta time)
in this time frame you will have downloaded a portion (delta download)
download speed at that moment (delta download / delta time)
providing delta time > 0
you need to tell the main form how much is downloaded and how fast it is going ...
for this you will send back info to the main form
for this i use a callback thread
your using your main form in your thread uses ... this will solve that problem too :)
oh yeah, here is how you create the proc from the main thread
type
TForm1 = class(TForm)
ProgressBar1: TProgressBar;
LabelMessage: TLabel;
LabelSpeed: TLabel;
private
fThread: TDownloadThread;
protected
procedure DownloadMsg(aMessage: string; aMessageInfo: Integer = 0);
public
procedure StartDownload(aUrl, aFileName: string);
end;
procedure TForm1.StartDownload(aUrl,
begin
fThread := TDownLoadThread.Create(aUr
end;
procedure TForm1.DownloadMsg(aMessag
begin
case aMessageInfo of
0: LabelMessage.Caption := aMessage;
1: ProgressBar1.Position := Round(StrToFloat(aMessage)
2: LabelSpeed.Caption := Format('%.2f kb/s', [StrToFloat(aMessage)]);
end;
end;
Business Accounts
Answer for Membership
by: Geert_GruwezPosted on 2008-11-01 at 13:59:46ID: 22858856
basically ?
before you start : save the starting time
when your done, (now - starttime) / filesize
// average in Kb/sec
function TimedDownload(Url, FileName: string): Double;
var aStartTime, aEndTime: TDateTime;
begin
Result := 0;
aStartTime := Now;
URLDownLoadToFile(Url, FileName);
if FileExists(FileName) then
Result := SecondSpan(Now, aStartTime) / (FileSize(FileName) / 1024);
end;