unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,ExtActns, StdCtrls, ComCtrls;
type
TForm1 =
class(TForm)
ProgressBar1: TProgressBar;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure URL_OnDownloadProgress
(Sender: TDownLoadURL;
Progress, ProgressMax: Cardinal;
StatusCode: TURLDownloadStatus;
StatusText:
String;
var Cancel: Boolean) ;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.URL_OnDownloadProgress;
begin
ProgressBar1.Max:= ProgressMax;
ProgressBar1.Position:= Progress;
end;
procedure TForm1.Button1Click(Sender: TObject);
const
URL='
http://www.sdr-kits.net/DG8SAQ/VNWA-installer.exe';
Dest= '
d:\VNWA-installer1.exe';
var
dl: TDownloadURL;
begin
dl := TDownloadURL.Create(self);
try
dl.URL :=
URL;
dl.FileName := Dest;
//dl.OnDownloadProgress := URL_OnDownloadProgress; //ExecuteTarget cashes if uncommented
dl.ExecuteTarget(
nil);
//this downloads the file
dl.Free;
except
dl.Free;
end;
end;
end.