troubleshooting Question

Downloading a large file with delphi "2 Gigs'

Avatar of Grant Fullen
Grant Fullen asked on
Delphi
7 Comments1 Solution1955 ViewsLast Modified:
I am trying to download a large file using delphi. code below.
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtActns, StdCtrls, ComCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    ProgressBar1: TProgressBar;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
        procedure URLOnDownloadProgress
        (Sender: TDownLoadURL;
         Progress, ProgressMax: Cardinal;
         StatusCode: TURLDownloadStatus;
         StatusText: String; var Cancel: Boolean) ;
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button2Click(Sender: TObject);
begin
Application.Terminate;
end;

procedure TForm1.URLOnDownloadProgress;
begin
   ProgressBar1.Max:= ProgressMax;
   ProgressBar1.Position:= Progress;
end;

procedure DoDownload;
begin
   with TDownloadURL.Create(nil) do
   try
     URL:='http://www.grantfullen.com/Delta Force Black Hawk Down.zip';
     FileName := 'c:\dforce.zip';
     OnDownloadProgress := Form1.URLOnDownloadProgress;

     ExecuteTarget(nil) ;
   finally
     Free;
   end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  DoDownload;
end;

end.
The form hangs and i can not termanate the process. I need to pause and resume the file.
ASKER CERTIFIED SOLUTION
aikimark
Get vaccinated; Social distance; Wear a mask
Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros