GeneSysDownloader

Started by Ehtyar, December 10, 2006, 11:39:44 AM

Previous topic - Next topic

Ehtyar

Hi all.

This project is a small, clean little
program as a novelty, and something of an example for the URLDownloadToFile API.
Initially it was just going to be a rampted up version of using the API itself,
a little user interface and whatnot, but thanks to Bitrider and ToutEnMasm, it is
now a far more impressive example of how one can simply download a file from the
internet with a minimum of fuss and/or excessive\messy code. I still have the old
version (using PBS_MARQUEE instead of a proper progress bar, and not making use of
the callback feature) and if a few are interested, i will post this as well. This
verson has been tested on Windows XP SP2 and Windows 2000 SP4.

KNOWN ISSUES/THINGS THAT PISS ME OFF
-Originally, i wanted to use the BIF_USENEWUI flag for the BrowseForFolderEx
function, but the function is incomplete IMHO as it can return NULL in the
path buffer, whilst retuning an success value. Thus the project no longer uses
that function, and the code for the basic version which is now used is inline
within the dialog proc.
-For some reason, URLDownloadToFile appears to return S_OK no matter what the
status of the downloaded file. This is a problem in two common instances:
   1) The user selected a read-only device to store the file, and
   2) The user was not connected to the internet at the time of download.
In each instance, the program will report that the download was successfully
completed. Until someone can either find out what mistake I've made, or finds
another way to check for errors it will continue to report false successes.
I do not consider the former issue to be a huge problem, though i have committed
several hours to determining why this is the case, and have thus far been unsuccessful,
other than a few hacks that I'm simply not happy with.

Finally, please feel free to make comments on this program and/or submit improvements etc.

Enjoy, Ehtyar.

[attachment deleted by admin]

Vortex

Ehtyar,

We are glad for your contribution, nice work.

trodon

hi Ehtyar, thats very nice example here, good job  :U
may i recomend some option for checking for autoupdate? ;)


PBrennick

Ehtyar,
This is very nice. A very useful tool. I will be adding it to the Webpage today or the day after today.

Paul
The GeneSys Project is available from:
The Repository or My crappy website

ramguru

Ehtyar,
I like what you did, how it looks and how it works. May I use it in my project. I will modify it to suit my needs. Is that OK with you ?

Ehtyar

Of course ramguru, it is a free-for-all project as far as reusing the source goes :)

Ehtyar.

Ehtyar

Forgive me trodon, i did not see your reply. If I were to be completely honest, i use this api simply because when i look at the winsock api, all i see is very strange voodoo witchcraft. This example was made because i know there are many others like me who would not dream of touching winsock, but will need to download a file or two from the internet on occasion. And what kind of download routine would it be if it didnt have a progress bar ;) So here we have it, download a file with a progress indicator without using winsock :)
If you happen to have some code that might help in reading the GeneSys version from somewhere on a webpage or whatnot, i'd be very excited to take a look :)

Ehtyar.

asmrixstar

This is very very good.  :U

Big fat thank you to you.

Ehtyar

And thank you for the feedback, I'm very pleased you like it :)

Ehtyar.

asmrixstar

#9
Finally a RELIABLE way to download files from the inet. :D

I loved your code so much I have nearly finished converting the Object into a a standalone dll (To make grabbing files off the net easier) and have hit a snag.

How do i resolve the target name of the the file?

Its easy with direct links to the filename ie.
http://www.masm32.com/masm.exe

But how the heck do i do it with something like this?
http://www.masm32.com/index.php?act=Downloads&do=download&id=4801

(both made up examples btw)
I would really apreciate anyones help on this.

I will ofcourse share the dll and code.

RE the errors
In the dll i intend to use the following 'work aounds' for these errors.
Please let me know what you think.

1) The user selected a read-only device to store the file, and
After checking if the file !exists i will attempt to write a 1 kb file (same name) to the device. This file is Automaticley overwitten by URLDownloadtoFile anyway without warning. So a check outside the download function is prefered anyway.

2) The user was not connected to the internet at the time of download.
mmm. there is winapi function to check Intet connectivity. ill have to look it up though

mnemonic

Quote from: asmrixstar on January 02, 2007, 03:07:49 AMBut how the heck do i do it with something like this?
http://www.masm32.com/index.php?act=Downloads&do=download&id=4801
One way would be that you parse the filename out of the response header; reference may be found here: http://tools.ietf.org/html/rfc2616#section-19.5.1
A different way would be to let the user enter a filename.

HTH
Be kind. Everyone you meet is fighting a hard battle.--Plato
-------
How To Ask Questions The Smart Way