Einzelnen Beitrag anzeigen

marabu

Registriert seit: 6. Apr 2005
10.109 Beiträge
 
#2

Re: FTP Download Geschwindigkeit anzeigen

  Alt 1. Okt 2005, 08:36
Hi,

schau dir die Zeilen mit //// an:

Delphi-Quellcode:
var
  dwStarted, dwElapsed: cardinal;
  dSpeed: double;

...
  dwBytesRead := 0;
  bufsize := READ_BUFFERSIZE;

  //// get a time reference
  dwStarted := GetTickCount;

  while (bufsize > 0) do
  begin
    Application.ProcessMessages;

    if not InternetReadFile(
      hFile,
      @buffer, // address of a buffer that receives the data
      READ_BUFFERSIZE, // number of bytes to read from the file
      bufsize
    ) then Break; // receives the actual number of bytes read

    if (bufsize > 0) and (bufsize <= READ_BUFFERSIZE) then
      BlockWrite(LocalFile, buffer, bufsize);
    dwBytesRead := dwBytesRead + bufsize;

    //// calculate time elapsed in ms
    dwElapsed := GetTickCount - dwStarted;
    //// dSpeed measured in KB/s
    dSpeed := dwBytesRead / (dwElasped * 1.024);

    { Show Progress }
    ProgressBar.Position := Round(dwBytesRead * 100 / fileSize);
    Form1.Label1.Caption := Format('%s of %s / %d %%', [
      FmtFileSize(dwBytesRead),FmtFileSize(fileSize) ,ProgressBar.Position
    ]);
  end;
...
Grüße vom marabu
  Mit Zitat antworten Zitat