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.

DLL Talk / Downloading with progress indicator - Is it possible in DB Pro?

Author
Message
Monzi
19
Years of Service
User Offline
Joined: 10th May 2004
Location: Denmark
Posted: 19th Apr 2006 18:06
I've asked this before. But i'm trying my luck again, is there ANY way to download via DB Pro and have some sort of progress indication? I know how to download via urlmon and so forth, but are there any other ways to do it so that you can get some kind of progress indication?
Olby
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location:
Posted: 19th Apr 2006 22:43
Yes, if im correct then Nicolas Kingsley coded a prog that will allow your program to update it self from any http adress with progress bar showing the process of downloading.

"Gangsters die, they don't go to heaven where angels fly!"
AMD Sempron 3.1+ Ghz, 512MB Ram, ATI R9550 256MB Ram, Sound Blaster Live!, WinXP SP2, DirectX 9.0c
CattleRustler
Retired Moderator
20
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 20th Apr 2006 01:08
spooky
21
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 20th Apr 2006 02:03
Also, take a look at this old post;

http://forum.thegamecreators.com/?m=forum_view&t=59361&b=6

There is some interesting code showing how to download files directly into a memblock buffer. It uses some very interesting windows dlls to download the file. Currently it is setup to download whole files at once, but looks like it's very easy to sequentially download a file in as many chunks as you want, giving you the option of showing a progress bar.

Boo!
Monzi
19
Years of Service
User Offline
Joined: 10th May 2004
Location: Denmark
Posted: 21st Apr 2006 18:16
Olby: tried it, it isnt suitable for my needs. Same goes for XUpdate cattlerustler.

Spooky: this seems VERY interesting. I'm looking into it right now :o)
Monzi
19
Years of Service
User Offline
Joined: 10th May 2004
Location: Denmark
Posted: 21st Apr 2006 23:05 Edited at: 21st Apr 2006 23:06
Ok, i've come some way with this project now. Now i only have ONE problem. I need to get the filesize of the file before the download starts.

I've found out that this can be done with this:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wininet/wininet/httpqueryinfo.asp
in the wininet.dll

but i dont understand how to translate this to DB Pro language. Can anyone help me? Spooky?
spooky
21
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 22nd Apr 2006 00:20
I'm no expert I'm afraid. I can see that command is certainly the one to use, specially the bit about HTTP_QUERY_CONTENT_LENGTH.

If no-one else comes up with the answer, I'll try and cobble something together over the weekend.

Boo!
Monzi
19
Years of Service
User Offline
Joined: 10th May 2004
Location: Denmark
Posted: 22nd Apr 2006 14:10 Edited at: 22nd Apr 2006 14:11
Spooky this is what i have so far. This gets the downloading done with sucess in 1024 byte chuncks. But the only thing i cant figure out how to use is the
test=call dll(1,"HttpQueryInfoA",url,HTTP_QUERY_CONTENT_LENGTH,fsize,ffsize,0)

spooky
21
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 23rd Apr 2006 00:05
Today is your lucky day. This dll stuff is quite interesting when start playing.

Code to determine filesize of a file on the internet BEFORE you download it - ideal for progress bar where you need to know size beforehand:



Boo!
Monzi
19
Years of Service
User Offline
Joined: 10th May 2004
Location: Denmark
Posted: 23rd Apr 2006 01:09
Great!

Thanx spook
spooky
21
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 23rd Apr 2006 01:25
Also, as an extra check that file actually exists, you can use another info check variable to get the http status code, like 200 = file exists, or 404 = file doesnt exist.

Add a new constant;



and some code;



Most important that buffersize is reset before each call to that dll as it expects it to be size of memblock on input, and then resets to size of requested info on output

Boo!
spooky
21
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 23rd Apr 2006 02:43 Edited at: 23rd Apr 2006 16:12
I got bored and tidied the code up a bit. I have remove the MAKE MEMORY command in favour of memblocks because I prefer them. Also note the use of HTTP_QUERY_FLAG_NUMBER which means that buffer is filled as a DWORD instead of ascii characters. Makes things much easier to understand.

I'll probably write something similar to your chunks download and make a suite of functions that I'll post in code snippets during the week.



Boo!
Monzi
19
Years of Service
User Offline
Joined: 10th May 2004
Location: Denmark
Posted: 23rd Apr 2006 17:53
Here is what i've put together:



It shows the progress in % and shows the speed of the download in kb/s.
Sayan Master
18
Years of Service
User Offline
Joined: 24th Jun 2005
Location:
Posted: 23rd Apr 2006 22:27
hello,

Monzi sorry to say that but your last code don't work, it would seem that the 'buffer' isn't filled properly.

Power is everything
Sayan Master
18
Years of Service
User Offline
Joined: 24th Jun 2005
Location:
Posted: 24th Apr 2006 08:10
sorry for the double post but i found the problem:

you defined buffer = get memblock ptr(1) and then buffer = get memblock ptr(2), so you overwrited the first value.

Power is everything
Monzi
19
Years of Service
User Offline
Joined: 10th May 2004
Location: Denmark
Posted: 24th Apr 2006 10:38 Edited at: 24th Apr 2006 10:41
Yes, thank you Sayan Master :o)

Here is the cleaned up and updated code:

Login to post a reply

Server time is: 2024-04-19 13:36:16
Your offset time is: 2024-04-19 13:36:16