unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdHTTP,
  StdCtrls, ComCtrls, IdAntiFreezeBase, IdAntiFreeze;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Button1: TButton;
    IdHTTP1: TIdHTTP;
    Label1: TLabel;
    Edit2: TEdit;
    ProgressBar1: TProgressBar;
    Label2: TLabel;
    procedure IdHTTP1Work(ASender: TObject; AWorkMode: TWorkMode;
      AWorkCount: Integer);
    procedure IdHTTP1WorkBegin(ASender: TObject; AWorkMode: TWorkMode;
      AWorkCountMax: Integer);
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

const v='1';
var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var stream: TMemoryStream;
begin
Button1.Enabled:=false;
stream:=TMemoryStream.Create;
idHTTP1.Get(Edit1.Text,stream);
stream.SaveToFile(Edit2.Text);
Button1.Enabled:=true;
end;

procedure TForm1.FormCreate(Sender: TObject);
var wersja: String;
begin
try
wersja:=idHTTP1.Get(Edit1.Text);
if wersja<>v then showmessage('Istnieje nowsza wersja programu o numerze: '+wersja);
except on E:Exception do
 ShowMessage(E.Message);
end;
end;

procedure TForm1.IdHTTP1WorkBegin(ASender: TObject; AWorkMode: TWorkMode;
  AWorkCountMax: Integer);
begin
ProgressBar1.Max:=AWorkCountMax;
end;

procedure TForm1.IdHTTP1Work(ASender: TObject; AWorkMode: TWorkMode;
  AWorkCount: Integer);
begin
ProgressBar1.Position:=AWorkCount;
Application.ProcessMessages;
end;

end.
