How do Delphi downloads an example of a network file

xiaoxiao2021-03-06  43

HTTP Download: (Delphi7) Downloading Network Files Using Design Indy Controls // Add controls in Form1: Two IdantiFreeze1, IDHTTP1; a button: Button1; a progress bar: Progressbar1 Display download speed Procedure TFORM1.BUTTON1CLICK (Sender: TObject); var MyStream: TMemoryStream; begin IdAntiFreeze1.OnlyWhenIdle: = False; // make the program is provided with a reaction MyStream: = TMemoryStream.Create; try IdHTTP1.Get ( 'http://www.appcontrols.com/demos/exe. /HTTPDemo.exe',MyStream); except Showmessage ( 'no download success!'); MyStream.Free; Exit; end; MyStream.SaveToFile (ExtractFilePath (paramstr (0)) 'HTTPDemo.zip'); MyStream.Free ShowMessage ('ok');

procedure TForm1.IdHTTP1WorkBegin (Sender: TObject; AWorkMode: TWorkMode; const AWorkCountMax: Integer);. begin // start the download before, the maximum size of the data set ProgressBar1 needs to receive ProgressBar1.Max: = AWorkCountMax; ProgressBar1.Min: = 0; progressbar1.position: = 0;

procedure TForm1.IdHTTP1Work (Sender: TObject; AWorkMode: TWorkMode; const AWorkCount: Integer); begin // when receiving data, will be displayed in the progress ProgressBar1 ProgressBar1.Position: = ProgressBar1.Position AWorkCount; end;.

转载请注明原文地址:https://www.9cbs.com/read-67144.html

New Post(0)