Code:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, URLMon, StdCtrls, ComCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
lbl_version: TLabel;
ProgressBar1: TProgressBar;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function DownloadFile(SourceFile, DestFile: string): Boolean;
begin
try
Result := UrlDownloadToFile(nil, PChar(SourceFile), PChar(DestFile), 0, nil) = 0;
except
Result := False;
end;
end;
procedure check;
const
VerSourceFile = 'http://www.google.com/images/logo_sm.gif';
DestFile = 'logo_sm.gif';
begin
if DownloadFile(VerSourceFile, DestFile) then
begin
end
else
ShowMessage('An error occurred')
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
check;
end;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, URLMon, StdCtrls, ComCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
lbl_version: TLabel;
ProgressBar1: TProgressBar;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function DownloadFile(SourceFile, DestFile: string): Boolean;
begin
try
Result := UrlDownloadToFile(nil, PChar(SourceFile), PChar(DestFile), 0, nil) = 0;
except
Result := False;
end;
end;
procedure check;
const
VerSourceFile = 'http://www.google.com/images/logo_sm.gif';
DestFile = 'logo_sm.gif';
begin
if DownloadFile(VerSourceFile, DestFile) then
begin
end
else
ShowMessage('An error occurred')
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
check;
end;
end.
Kako da uz pomoc progress bara prikazem koliko je preostalo da se preuzme fajl...
Ako moze neki primer koda?
Hvala unapred.