This is a demo of downloading a file from the internet using the WinAPI.
My VC++ help file says
Windows NT: Use version 5.0 or later.
But I am nearly sure “URLDownloadToFileA” works on all versions of Windows? I tested on WinXP.
Does it work on older systems?
Code: Select all
function downloadfromweb (byval szURL as zstring ptr, _
byval szFileName as zstring ptr) as integer
dim r as integer
dim library as integer
dim URLDownloadToFile as function (byval pCaller as any ptr, _
byval szURL as zstring ptr, _
byval szFileName as zstring ptr, byval dwResv as uinteger, _
byval lpfnCB as any ptr) as integer
library = dylibload("urlmon")
if library = 0 then return 1
URLDownloadToFile = dylibsymbol (library, "URLDownloadToFileA")
if URLDownloadToFile = 0 then return 1
r = URLDownloadToFile(0, szURL, szFileName, 0, 0)
function = r
i = downloadfromweb("http://www.freewebs.com/weekendcode/FBStyle.zip","FBStyle.zip")
if i = 0 then print "Download suceeded" else print "Download failed"
The return 0 will not work so I changed it to return 1 to generate an error if the DLL or function cannot be found