^ Know it can be used
NMHTTP control downloads web pages, but D7 can't find this control. ^ Found idhttp control seems to be to achieve the same functionality, but it's too little discussion of online ^ excerpt bit of code: ____________________________________________________________________________________________
The INDY component of the control directly with the Delphi comes directly as an example. New project, put a TIDHTTP control, a Tidantifreeze control, a tprogressbar is used to display the download progress. Finally put a TButton to start performing our command. Code is as follows : procedure TForm1.Button1Click (Sender: TObject); // clicks on the button to start the download our files varMyStream: TMemoryStream; beginIdAntiFreeze1.OnlyWhenIdle: = False; // set the program to respond .MyStream: = TMemoryStream.Create; tryIdHTTP1. GET ('http://www.138soft.com/download/mp3toexe.zip' ,.Mystream); // Download your site Zip file Except // Indy control usually use this Try..Except structure .ShowMessage 'network error!'); MyStream.Free; Exit; end; MyStream.SaveToFile ( 'c: /Mp3ToExe.zip'); MyStream.Free; Showmessage ( 'OK'); end; procedure TForm1.IdHTTP1WorkBegin (Sender: TObject , AWorkMode: TWORKMODE; Const AWORKCOUNTMAX: INTEGER); // Before starting download, set the maximum value of ProgressBar1 to the data required to receive. BeginProgressbar1.max: = aworkcountmax; progressbar1.min: = 0; progressbar1.position: = 0 ; end; procedure TForm1.IdHTTP1Work (Sender: TObject; AWorkMode: TWorkMode; const AWorkCount: Integer); // receiving data, the schedule will be displayed in .beginProgressBar1.Position ProgressBar1: = ProgressBar1.Position AWorkCount; end; IdHTTP1 There is also a form of get to get strings: for example, the above program can be rewritten: Procedure T Form1.button1click (Sender: TOBJECT); varmystr: string; beginidantifreeze1.onlywhender: = false; // setting makes the program react .Trymystr: = idHttp1.get ('http://www.138soft.com/default.htm' ); exceptShowmessage ( 'network error!'); Exit; end; Showmessage (MyStr); end; ___________________________________________________________________________________________