Page 1 of 1

How to call "URLDownloadToFile " function by PB?

Posted: Wed Dec 01, 2010 3:31 am
by dongnanyanhai
My code did not work!

Code: Select all

Prototype.l URLDownloadToFile(pCaller.i,*szURL.c,*szFileName.c,dwReserved.l,*fun)
url.s = "http://www.google.com/"
filename.s = "index.htm"
*szURL.c = @url
*szFileName.c = @filename
If OpenLibrary(0,"urlmon.dll")
  Debug CallFunction(0,"URLDownloadToFile",#Null,*szURL.c,*szFileName.c,0,#Null)
  Debug GetLastError_()
EndIf
Could any one tell me how to call the "URLDownloadToFile " function!

About URLDownloadToFile function:http://msdn.microsoft.com/en-us/library ... S.85).aspx

Re: How to call "URLDownloadToFile " function by PB?

Posted: Wed Dec 01, 2010 9:56 am
by Kiffi
@dongnanyanhai:

Code: Select all

Result = ReceiveHTTPFile(URL$, Filename$)
http://purebasic.com/documentation/http ... pfile.html

Greetings ... Kiffi

Re: How to call "URLDownloadToFile " function by PB?

Posted: Wed Dec 01, 2010 11:34 am
by Shardik
dongnanyanhai wrote:Could any one tell me how to call the "URLDownloadToFile " function!
You should try Kiffi's hint and use the native PureBasic solution which is even crossplatform.
But if you nevertheless want to use URLDownloadToFile(), try a previous code example which
already answered your question:
http://www.purebasic.fr/english/viewtop ... 35&start=3

However you should modify my example by inserting

Code: Select all

DeleteURLCacheEntry_(URL)
before calling URLDownloadToFile().

Re: How to call "URLDownloadToFile " function by PB?

Posted: Sat Dec 11, 2010 9:55 pm
by jesperbrannmark
The receivehttpfile command might be os independant. But there are some problems with it (at least in win), just a hint since i almost went insaine before i realised the problem:
http://www.purebasic.fr/english/viewtop ... =4&t=44242