Monday, February 07, 2005 6:48 PM bart

Using BITS in IE - an update

A couple of posts ago I talked about the use of BITS for large downloads. If you want to go one step further and you want to get rid of the command-prompt to do this stuff, you can use the BITS API directly. There is a wrapper available via http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwxp/html/WinXP_BITS.asp. When you install the MSI, you can retrieve the .NET assembly Microsoft.Msdn.Samples.BITS.dll and import it in your project. The rest is pretty straightforward. Last but not least, IE definitely rocks (no, I don't want any religious debates on the browser choice over here at my blog) thanks to it's extensibility mechanism for the context menu. Let's explain how:

First, create a HTM file with the following content and store it somewhere in a safe location that can be read by IE:

In there, reference to the executable with your BITS-download manager written using the BITS wrapper as explained earlier. It has to take in one command line argument (you know, public void Main(string[] args) with args containing one element) which will get the URL.

Next, add a registry entry for an IE Menu Extension to call the BITS download manager. Over here I show you the output of my regedit dump of that key:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\&Download using BITS]
@="c:\\temp\\bits.htm"
"Contexts"=dword:00000020

Very simple indeed, just reference to the HTML file and set the context to 20 (which enables the context menu on links).

The result looks like this:

And finally, add whatever features you want to your download manager. Remember that you need to check for completed tasks and when a task has completed you need to "close the task" in order to get the file on disk with the correct filename. An idea is to create a system tray application that allows you to start a new download, to monitor existing downloads (you can ask for the downloadstatus of every download), to pause/resume jobs, to cancel jobs and to get a notification when the download has completed. If I ever have some time left... :-)

Del.icio.us | Digg It | Technorati | Blinklist | Furl | reddit | DotNetKicks

Filed under:

Comments

# re: Using BITS in IE - an update

Friday, February 18, 2005 10:35 AM by bart

A C# download manager using BITS can be found here http://bits.language.nu/

# re: Using BITS in IE - an update

Saturday, February 26, 2005 11:02 AM by bart

Bart,

Where is the HTM file?

Thanks

# re: Using BITS in IE - an update

Friday, July 01, 2005 5:33 PM by bart

Thanks for the information. I need some help to go just a bit further on this.
What I need is, instead of a right click (context menu) and then select to download using a Custom App (which uses BITS), I want, when the user Clicks on the Download Link itself, the same app (which uses BITS) to be invoked automatically (overrriding the standard IE download dialog-box etc).

Can anyone help?

Regards
Satish.