Einzelnen Beitrag anzeigen

iphi

Registriert seit: 13. Feb 2009
262 Beiträge
 
Delphi 7 Personal
 
#1

Problem mit TDownloadURL

  Alt 5. Nov 2012, 12:37
Delphi-Version: 6
Hallo,

ich versuche mit meinem Code eine Datei aus dem Internet herunterzuladen:

Delphi-Quellcode:
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.
Das Herunterladen funktioniert, aber wenn ich den OnDownloadProgress zuweise, dann macht der ExecuteTarget eine Exception 'Invalid Enum Value'.

???
  Mit Zitat antworten Zitat