unit UUpdater;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdHTTP, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
xpman, Gauges, ComCtrls, UDownThread,
zlib, Grids, BaseGrid, AdvGrid;
type
TForm1 =
class(TForm)
Button1: TButton;
Status: TLabel;
SpeedLabel: TLabel;
msg: TMemo;
Progress: TProgressBar;
Edit1: TEdit;
Button2: TButton;
Button3: TButton;
StringGrid1: TAdvStringGrid;
Button4: TButton;
Edit2: TEdit;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
StartTime: Cardinal;
procedure download(wwwurl:
string);
procedure OnThreadWork(Sender: TThread; AWorkCount: Integer);
procedure OnThreadWorkBegin(Sender: TThread; AWorkCountMax: Integer);
// procedure DownResultHandle(Sender: TObject; ResponseCode: Integer);
public
{ Public declarations }
end;
var
Form1: TForm1;
abbruch :Boolean;
ndx:integer;
implementation
{$R *.dfm}
procedure TForm1.OnThreadWork(Sender: TThread; AWorkCount: Integer);
var
speed: single;
begin
Progress.Position := AWorkCount;
speed := AWorkCount/(GetTickCount - StartTime + 1);
//+1 um DivbyZero zu verhindern
Status.caption := Format('
%f s|%.2f KB/s', [(((Sender
as TDownThread).WorkCountMax-AWorkCount)/1000)/speed, speed]);
end;
procedure TForm1.OnThreadWorkBegin(Sender: TThread; AWorkCountMax: Integer);
begin
Progress.Max := AWorkCountMax;
msg.Lines.Append(FormatFloat('
Dateigröße: 0, Bytes', AWorkCountMax));
StartTime := GetTickCount;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
msg.Lines.Append('
--------------------------');
msg.Lines.Append('
Starte Download ...');
download('
http://localhost/tools/checkhttp.php?name='+ edit1.text);
msg.Lines.Append('
Download abgeschlossen');
SpeedLabel.Caption := '
Fertig';
Button2.Click;
end;
procedure TForm1.download(wwwurl:
string);
var
path:
string;
Down: TDownThread;
begin
path := ExtractFilePath(paramstr(0)) + '
Update\tmp.txt';
Status.Caption := '
';
Progress.Position := 0;
msg.Lines.Append('
Downloade Datei ' + path);
Down := TDownThread.Create(true);
with Down
do
begin
FreeOnTerminate := true;
OnWork := OnThreadWork;
OnWorkBegin := OnThreadWorkBegin;
// OnFinish := DownResultHandle;
URL := wwwurl;
FileName := path;
Resume;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
ndx:=1;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
s:
string;
begin
abbruch := false;
while (ndx < StringGrid1.RowCount - 1)
and (
not abbruch)
do // war sonst 0
begin
edit1.text:= StringGrid1.Cells[4, ndx];
//name
abbruch := true;
inc(ndx);
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
abbruch := True;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
StringGrid1.LoadFromCSV(ExtractFilePath(Application.ExeName) + '
komma.csv');
end;
end.