Download einer Datei mit der TDownLoadURL - Action. Da diese Komponente DLL's des IE nutzt, braucht der Entwickler keine weiteren Einstellungen (Proxy ...) vorsehen.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, StdCtrls,
ExtActns;
type
TForm1 = class(TForm)
Button1: TButton;
ProgressBar1: TProgressBar;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
procedure Progress(Sender: TDownLoadURL; Progress, ProgressMax: Cardinal; StatusCode: TURLDownloadStatus; StatusText: string; var Cancel: Boolean);
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
with TDownLoadURL.Create(nil) do
try
URL := 'http://../test.txt'; // URL der Datei
Filename := '...\test.txt'; // Name der Datei
OnDownloadProgress := Progress; // Status des Downloads anzeigen
Execute;
finally
Free;
end;
end;
procedure TForm1.Progress(Sender: TDownLoadURL; Progress, ProgressMax: Cardinal; StatusCode: TURLDownloadStatus;
StatusText: string; var Cancel: Boolean);
begin
ProgressBar1.Max:=ProgressMax;
ProgressBar1.Position:=Progress;
Caption:=StatusText;
end;
end.
Tags: Delphi Delphi 2009