Link to home
Start Free TrialLog in
Avatar of brunner
brunner

asked on

trap a download in ie4 to own application.

I would like to know how to trap the download of a file from within my own application and handle the download, i also need to obtain the URL from which they clicked the file, the url that the file is coming from.  If you could post any information, URLS for information, sample source code or anything, it would be appreciated.

Avatar of rwilson032697
rwilson032697

You could set up a helper application that was associated with the appropriate file type. Then ie4 should do it automatically...

I think it is something concerning registry.

Have you ever used GetRight? It can set Netscape/IE to use it as default downloader, when you enter a url in netscpe, it is first transfered to GetRight. (So sometimes if you imroperly remove GetRight, Netscape will refuse to respond for any url.)

I had serached for registry for "getright" and found that it add something to Netscape's registry information. So you can have a try and find what may help.
To capture the selection of a file to download you will have to write an application that registers itself with IE's COM event interface.

IE supports the DWebBrowserEvents1 and DWebBrowserEvents2 interfaces, both of which have the methods DownloadBegin and DownloadComplete.

I would imagine that you will have to create an event sink in your application, wrap the outgoing interface from IE and register your application in the outgoing interface's ConnectionPoint.

With this done you should be able to receive notification of download events. I don't have time to try this at the moment, but I shall try this evening.


The solution is a registry addition that tells IE what to do with certain URL types, for instance telnet://  with open telnet etc.

By changing or adding values you can cause IE to shell your application - you could even handle http:// yourself rather than IE.......

The entries are stored under HKEY_CLASSES_ROOT in the registry, surprisingly http represents what to do with http:// urls etc....

So if you wanted a URL type called fred you could create a new key called fred etc.....  The full definition of the registry key is as follows....

[HKEY_CLASSES_ROOT]    
[fred]
        (Default) = "URL:Fred Protocol"
        URL Protocol = ""
        [DefaultIcon]
            (Default) = "fred.exe"
        [shell]
            [open]
                [command]
                    (Default) = "c:\<yourpath>\fred.exe %1"

The standard compliment of commands are supported under the shell\open entry (ie you can use other verbs other than command).

If you want further information let me know and I will dig up the MSDN reference for this and post it here....

Good Luck

Zac
Avatar of brunner

ASKER

Zac,

Thanks for that information however for 200 points I am after a little more of an answer and some code as well..

What you have written may technically be correct however it does not help me enough to achieve the result that i need. I don't want to take control of all downloads, only file downloads and only when my application is loaded. There may be some sort of WM_ message that needs to be called or something..

Avatar of brunner

ASKER

Adjusted points to 250
ASKER CERTIFIED SOLUTION
Avatar of uuuppz
uuuppz

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for concluding my thoughts uuuppz - just didn't have time to finish it off myself... Cheers

John.