Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Downloading a file from internet?
#1
I tried to make it work in freebasic but no luck so far :oops:

It is supposed to download a txt file from a specific location. It compiles fine but it doesn’t download the file. Any thoughts what I am doing wrong.

Code:
'' Function FGetFileHTTP_URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByRef szURL As String, ByRef szFileName As String,ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
'$include: 'win\kernel32.bi'
Dim dummy as long
Dim url$
Dim OFile$
url$="http://www.ase.gr/content/gr/MarketData/Stocks/Prices/Files/txt/20050221.txt"
OFile$="quotes.txt"
Dim FGetFileHTTP_URLDownloadToFile as function (ByVal pCaller As Long, ByRef szURL As String, ByRef szFileName As String,ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
   dim hlib as integer
   hlib = LoadLibrary("urlmon.dll")
   FGetFileHTTP_URLDownloadToFile = GetProcAddress( hlib, "URLDownloadToFileA" )
   dummy = FGetFileHTTP_URLDownloadToFile (0, url$, OFile$,0, 0)
sleep
Reply
#2
Perhaps you're supposed to open a socket using winsock before calling this function...
Antoni
Reply
#3
Try redeclaring all string arguments as BYVAL, that will tell FB to pass the address of the string data (that what the API wants), not the string descriptor (that what BYREF will do).
Reply
#4
:bounce: Thanks a lot !!! The code is working now.

Code:
'$include: 'win\kernel32.bi'
Dim dummy as long
Dim url$
Dim OFile$
url$="http://www.ase.gr/content/gr/MarketData/Stocks/Prices/Files/txt/20050221.txt"
OFile$="quotes.txt"
Dim FGetFileHTTP_URLDownloadToFile as function (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String,ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
   dim hlib as integer
   hlib = LoadLibrary("urlmon.dll")
   FGetFileHTTP_URLDownloadToFile = GetProcAddress( hlib, "URLDownloadToFileA" )
   dummy = FGetFileHTTP_URLDownloadToFile (0, url$, OFile$,0, 0)
sleep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)