Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / download a file with URLDownloadToFile

Author
Message
sberk
16
Years of Service
User Offline
Joined: 6th Jun 2010
Location: next to a cup of coffee
Posted: 31st May 2011 12:27
Hi,
I'm using URLDownloadToFile to download a file. The point that this downloading happens in the background, while the main loop runs unaffected, is a point I really enjoy about this function.
However, I have some problems to determine wether the download is finished. The return code obviousluy only indicates whether the download is started.
Can anybody give me clue what\'s the best way to determine whether the download is finished?
yours
sberK

Hodgey
16
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 31st May 2011 12:38
I don't know much about this sort of thing but it appears that you have a typo in your function. You have "endfunction faile", is it supposed to be endfunction failed?

A clever person solves a problem, a wise person avoids it - Albert Einstein
sberk
16
Years of Service
User Offline
Joined: 6th Jun 2010
Location: next to a cup of coffee
Posted: 31st May 2011 13:13
Thanks,
yes this is a typo. I just c&p it from my source code and missed the last bit. Thank you very much.
sberK
Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 2nd Jun 2011 04:48 Edited at: 2nd Jun 2011 04:48
I took a look at this, and I can't be of much help, but I'll leave the windows docs here, in case they help.


Tell me if there's a broken link to images in a thread I post, and I'll fix 'em.
SH4773R
16
Years of Service
User Offline
Joined: 18th Jan 2010
Location: AMERICA!!!
Posted: 2nd Jun 2011 06:43 Edited at: 2nd Jun 2011 06:45
Quote: "It should be noted that this function requires you have already called CoInitializeEx() in your program or it will fail to operate. In my case, it didn't return any error codes it just hung up the program indefinitely until I included this explicit COM initalization step."


Does this mean anything to you guys?
It seems the .dll is dependant on other commands.

Also whats wrong with FTP?

Wyldhunt
16
Years of Service
User Offline
Joined: 27th Sep 2009
Location: The Dark Side
Posted: 5th Jun 2011 11:36 Edited at: 5th Jun 2011 11:40
You may be able to run the following function in your main loop after you run your download function. Assuming that it doesn't create a file with the proper name immediately upon the start of the download (If it downloads to a temp directory/file in the background), then this would work. I don't know enough about the specific functions to help more than basic brainstorming though. Sorry.

EDIT:
For FTP stuff, you may also want to look at this DLL:
http://forum.thegamecreators.com/?m=forum_view&t=185283&b=1
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 5th Jun 2011 20:08
@Wyldhunt: the file will probably be created at the beginning of the download and then appended until the transfer is complete.

If you don't mind using a plugin, I threw together this which should solve the problem (it also allows you to query the current download progress, with which you could update a bar or something to show the player / user that your application hasn't frozen ).


"Why do programmers get Halloween and Christmas mixed up?"
sberk
16
Years of Service
User Offline
Joined: 6th Jun 2010
Location: next to a cup of coffee
Posted: 6th Jun 2011 13:02
Hi,
thanks a lot. I definitly try it during the next few hours. Looks exactly like the thing I'm looking for.
Thank you very much,
sberK

Login to post a reply

Server time is: 2026-07-11 02:13:33
Your offset time is: 2026-07-11 02:13:33