Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's some sample code that uses Indy. This code is for Delphi 2010 (with Indy 10?), but the code for Delphi 7 would be similar. I've used Indy for years with D7 and have been very happy with it. I think in D7 we use Indy 9. Check if you need to download a new version...</p> <p>You can use OnWork and OnWorkBegin to add a progress meter if you need to.</p> <p>This code I excerpted from a bigger piece, editing it a bit. I did not try compiling it, but it will give you a good starting place.</p> <pre><code>function Download( const aSourceURL: String; const aDestFileName: String; out aDownloadResult: TDownloadResult; out aErrm: String): boolean; var Stream: TMemoryStream; IDAntiFreeze: TIDAntiFreeze; begin aDownloadResult := DROther; Result := FALSE; fIDHTTP := TIDHTTP.Create; fIDHTTP.HandleRedirects := TRUE; fIDHTTP.AllowCookies := FALSE; fIDHTTP.Request.UserAgent := 'Mozilla/4.0'; fIDHTTP.Request.Connection := 'Keep-Alive'; fIDHTTP.Request.ProxyConnection := 'Keep-Alive'; fIDHTTP.Request.CacheControl := 'no-cache'; IDAntiFreeze := TIDAntiFreeze.Create; Stream := TMemoryStream.Create; try try fIDHTTP.Get(aSourceURL, Stream); if FileExists(aDestFileName) then DeleteFile(PWideChar(aDestFileName)); Stream.SaveToFile(aDestFileName); Result := TRUE; aDownloadResult :=drSuccess; except On E: Exception do begin Result := FALSE; aErrm := E.Message + ' (' + IntToStr(fIDHTTP.ResponseCode) + ')'; end; end; finally Stream.Free; IDAntiFreeze.Free; fIDHTTP.Free; end; end; { Download } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload