URLDownloadToFile

From wiki.visual-prolog.com

The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

For downloading, there is a Windows API called URLDownloadToFile which can do the job.

In your program, add the lines:

class predicates
    uRLDownloadToFile : (handle, string URL, string File, unsigned Reserved, unsigned Callback) 
        -> unsigned Hresult language apicall.
 
class predicates
    doDownload : (string SourceURL, string Destfile) [used].
clauses
    doDownload(SourceURL, Destfile) :-
        Hresult = uRLDownloadToFile(nullHandle, SourceURL, Destfile, 0, 0),
        if winErrors::s_ok <> Hresult then
            exception::raise_nativeCallException("URLDownloadToFile", Hresult,
                [namedValue("SourceURL", string(SourceURL)), namedValue("Destfile", string(Destfile))])
        end if.