Downloading a file in Delphi

后端 未结 3 990
夕颜
夕颜 2020-12-14 19:54

A google search shows a few examples on how to download a file in Delphi but most are buggy and half of the time don\'t work in my experience.

I\'m looking for a si

3条回答
  •  無奈伤痛
    2020-12-14 20:43

    The second approach is the standard way of using Internet resources using WinINet, a part of Windows API. I have used it a lot, and it has always worked well. The first approach I have never tried. (Neither is "very complicated". There will always be a few additional steps when using the Windows API.)

    If you want a very simple method, you could simply call UrlMon.URLDownloadToFile. You will not get any fine control (at all!) about the download, but it is very simple.

    Example:

    URLDownloadToFile(nil,
                      'http://www.rejbrand.se',
                      PChar(ExtractFilePath(Application.ExeName) + 'download.htm'),
                      0,
                      nil);
    

提交回复
热议问题