How to call "URLDownloadToFile " function by PB?

Windows specific forum
dongnanyanhai
User
User
Posts: 10
Joined: Thu Aug 05, 2010 4:15 pm

How to call "URLDownloadToFile " function by PB?

Post 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
User avatar
Kiffi
Addict
Addict
Posts: 1485
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

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

Post by Kiffi »

@dongnanyanhai:

Code: Select all

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

Greetings ... Kiffi
Hygge
User avatar
Shardik
Addict
Addict
Posts: 2058
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

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

Post 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().
jesperbrannmark
Enthusiast
Enthusiast
Posts: 536
Joined: Mon Feb 16, 2009 10:42 am
Location: sweden
Contact:

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

Post 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
Post Reply