News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Download from web

Started by AeroASM, May 26, 2005, 03:05:29 PM

Previous topic - Next topic

AeroASM

I would like to make a program that when run downloads a particular file from the internet to my hard drive. Is there an easy way to do this, or do I have to use sockets and do everything manually?

doomsday

I haven't played with programming and the net, but I'd suggest having a look at the FTPxxx APIs in your Windows docs.  Might be of some use.

regards,
-Brent

Tedd

You can either do it the long way with sockets and handling all the http or ftp yourself..
Or you can use the Winsock 2 functions to handle most of the http/ftp stuff for you, but you still need to play with sockets and such :wink
(The functions are in "wininet.inc" - named, cleverly, Http.... and Ftp....)
No snowflake in an avalanche feels responsible.

AeroASM

Thanks Tedd, I will research this.

If the file I want to download is of the form http://www.thing.com/thing.gif do I use Http... or Ftp...? I thought maybe Ftp because isn't Http designed specifically for HTML documents?

Also will this work under proxy?

pbrennick

In the DL section on Iczelion's website is an example that does this.  He also has an example that opens a zip file and gets a particular file to download.  These are not in the Tutorial section but are in the DL section.

Paul

Tedd

See in the url where is says "http://" - guess which one you should use  :wink
Http is used for files, whether they are webpages or pictures or binary files doesn't matter.
Equally, if the url is "ftp://" then you need to use ftp, but for most cases http is fine.

As for proxies... you should be okay, if there's anything to deal with, then those functions should take care of it.


* Iczelion's download program is a quick and dirty version, which does the http itself; it doesn't handle anything special, so it works when nothing goes wrong, otherwise it fails.
No snowflake in an avalanche feels responsible.

Faiseur

"If the file I want to download is of the form http://www.thing.com/thing.gif do I use Http... or Ftp...? I thought maybe Ftp because isn't Http designed specifically for HTML documents?"

Hi AeroASM,

example "HTTP Downloader v1.5" of Iczelion is a little old... Simplest is with API "UrlDownloadToFile" (in your example "http").  Otherwise it is a little longer (but easy) with API Wininet (InternetOpen, InternetOpenUrl, InternetReadFile)... 

I do not know if I can show examples (?), it is also used in hack (webdownloader).

French asm Forum: http://www.asmforum.net/   Website: http://www.faiseur.net/

Robert Collins

Quote from: AeroASM on May 26, 2005, 04:24:36 PM
If the file I want to download is of the form http://www.thing.com/thing.gif.....

Just put that link in the address window of your browser and it will download the thing.gif file for you or you can right click on the image that you see on the HTML document in either case it will be saved to your specified directory.

AeroASM

Faiseur: Thanks, UrlDownloadToFile looks perfect.
Robert: I want it to be done automatically by my program.

Robert Collins

Quote from: AeroASM on May 26, 2005, 06:34:41 PM
Faiseur: Thanks, UrlDownloadToFile looks perfect.
Robert: I want it to be done automatically by my program.

Oh, then that UrlDownloadToFile is the way to go

hutch--

If you want to do this as simple as possible, if I remember correctly you can do this with ShellExecute() by specifying a URL.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

thomasantony

Hi hutch,
   When you use ShellExecute it won't be exactly automatic. You will have to deal with the dialog box and all give the directory to save to etc. Best way, connect to port 80 send the command GET thing.gif . I think thats the way it works

Thomas :U
There are 10 types of people in the world. Those who understand binary and those who don't.


Programmer's Directory. Submit for free

Faiseur

I think that you did not test UrlDownloadToFile

:-)

French asm Forum: http://www.asmforum.net/   Website: http://www.faiseur.net/

Robert Collins

Quote from: thomasantony on May 27, 2005, 05:21:11 AM
.....Best way, connect to port 80 send the command GET thing.gif . I think thats the way it works

That's the way I do it. There's one little problem however. If the server is a secured server (https) then you will have the secured handshaking stuff to wotk out and that's not easy and you don't connect on port 80 if it is https.

Danesh

AeroASM,

If you have access to the server which you want to download from, or if you want to implement an automatic updater or something like that, you can write a server program which listens on a specified port and then communicate to the server from the program which wants to download something. Writing server program and communicate with it is so easy. In this way, you can also pass username, password, do any kind of encryption during sending, manage multiple connections, get any other information from the host before sending any file to it (this is useful for example for an update server to see which version should be sent to the host by evaluating its current version) and so on. If you decided to do so, just tell me. I have many source codes which you can use just by little changes. Also, in more complex cases you can use James' FastServer utility, downloadable from: http://www.jamesladdcode.com