Difference between revisions of "URLDownloadToFile"
From wiki.visual-prolog.com
m (categorized) |
(update) |
||
Line 4: | Line 4: | ||
<vip>class predicates | <vip>class predicates | ||
urlDownloadToFile : (unsigned, string URL, string File, unsigned Reserved, unsigned Callback) -> unsigned Hresult | |||
language apicall as "URLDownloadToFile". | language apicall as "URLDownloadToFile". | ||
class predicates | class predicates | ||
doDownload : (string SourceURL, string Destfile). | doDownload : (string SourceURL, string Destfile). | ||
clauses | clauses | ||
doDownload(SourceURL, Destfile) :- | |||
Hresult = uRLDownloadToFile(0,SourceURL,Destfile,0,0), | Hresult = uRLDownloadToFile(0, 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.</vip> | |||
[[Category:Examples]] | [[Category:Examples]] | ||
[[Category:Internet]] | [[Category:Internet]] | ||
[[Category:Tips and Tricks]] | [[Category:Tips and Tricks]] |
Revision as of 19:50, 22 March 2016
For downloading, there is a Windows API called URLDownloadToFile which can do the job. This API needs urlmon.dll which is present in all Windows.
In your program, add the lines:
class predicates urlDownloadToFile : (unsigned, string URL, string File, unsigned Reserved, unsigned Callback) -> unsigned Hresult language apicall as "URLDownloadToFile". class predicates doDownload : (string SourceURL, string Destfile). clauses doDownload(SourceURL, Destfile) :- Hresult = uRLDownloadToFile(0, 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.