[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Kevin Cochran

6/27/2007 11:44:00 PM

Greetings,

I am trying to make a custom download manager in c#. The code compile, I
register it with gacutil and regasm, but when I open IE and click on a link
to download, I get the standard IE download dialog. Is there something I'm
missing? I am new to COM, so any help would be appreciated. Here is my
complete code:

/* BEGIN CODE */
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace MyDownloader
{
[ComImport, GuidAttribute("988934A4-064B-11D3-BB80-00104B35E7F9"),
InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown),
ComVisible(false)]
public interface IDownloadManager
{
void Download(
System.Runtime.InteropServices.ComTypes.IMoniker pmk,
System.Runtime.InteropServices.ComTypes.IBindCtx pbc,
UInt32 dwBindVerb,
Int32 grfBINDF,
IntPtr pBindInfo,
String pszHeaders,
String pszRedir,
UInt32 uiCP
);
}

[ComImport, Guid("988934A4-064B-11D3-BB80-00104B35E7F9")]
public interface Downloader
{
}

[Guid("78BC4A4C-63B7-41CC-B287-858663AF4281"),
ClassInterface(ClassInterfaceType.None)]
public class MainClass : IDownloadManager
{
public MainClass()
{
}

public void Download(
System.Runtime.InteropServices.ComTypes.IMoniker pmk,
System.Runtime.InteropServices.ComTypes.IBindCtx pbc,
UInt32 dwBindVerb,
Int32 grfBINDF,
IntPtr pBindInfo,
String pszHeaders,
String pszRedir,
UInt32 uiCP)
{
MessageBox.Show("Got it!");
}
}
}
/* END CODE */

Thanks,
Kevin

7 Answers

(Mattias Sjögren)

6/28/2007 5:37:00 AM

0

Kevin,

>I am trying to make a custom download manager in c#. The code compile, I
>register it with gacutil and regasm, but when I open IE and click on a link
>to download, I get the standard IE download dialog. Is there something I'm
>missing?

Have you registered the download manager in the Registry?

Also, I believe you have to add the [MarshalAs(UnmanagedType.LPWStr)]
attribute to the pszHeaders and pszRedir parameters.


Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.n... | http://www.dotneti...
Please reply only to the newsgroup.

Kevin Cochran

6/28/2007 2:40:00 PM

0

Hi Mattias,

> Have you registered the download manager in the Registry?

I assumed that regasm did this for me. I had also used regsvcs, but it did
not change the results. Is there some other way to register my control?

Thanks,
Kevin

(Mattias Sjögren)

6/28/2007 5:27:00 PM

0

Kevin,

>I assumed that regasm did this for me.

It will only handle normal COM registration (unless you add additional
code in a ComRegisterFunction). Not the special registration
requirements for download managers

http://msdn2.microsoft.com/en-us/library/aa7...


Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.n... | http://www.dotneti...
Please reply only to the newsgroup.

Kevin Cochran

6/28/2007 6:42:00 PM

0

Hi Mattias,

Perfect! Thanks for your help. There is still one problem, though, which is
a bit strange. For most downloads, this works. But there is a site which
pushes the file bits via an ADO Stream object. In this scenario, IE does not
use the download manager, but instead uses it's built-in. The content type
varies (application/octet-stream, audio/mp3, video/wmv, etc.), and the file
name is set properly in the content disposition.

Do you have any idea about this? Is there another interface I need to
implement in order to catch all downloads?

Thanks,
Kevin


"Mattias Sjögren" wrote:

> Kevin,
>
> >I assumed that regasm did this for me.
>
> It will only handle normal COM registration (unless you add additional
> code in a ComRegisterFunction). Not the special registration
> requirements for download managers
>
> http://msdn2.microsoft.com/en-us/library/aa7...
>
>
> Mattias
>
> --
> Mattias Sjögren [C# MVP] mattias @ mvps.org
> http://www.msjogren.n... | http://www.dotneti...
> Please reply only to the newsgroup.
>

Kevin Cochran

6/28/2007 8:06:00 PM

0



"Mattias Sjögren" wrote:

> Kevin,
>
> >I assumed that regasm did this for me.
>
> It will only handle normal COM registration (unless you add additional
> code in a ComRegisterFunction). Not the special registration
> requirements for download managers
>
> http://msdn2.microsoft.com/en-us/library/aa7...
>
>
> Mattias
>
> --
> Mattias Sjögren [C# MVP] mattias @ mvps.org
> http://www.msjogren.n... | http://www.dotneti...
> Please reply only to the newsgroup.
>

Kevin Cochran

6/28/2007 8:08:00 PM

0

It looks like a specific problem with the Content-Disposition header, and can
be solved with RegisterBindStatusCallback. Any idea about how I would
implement that?

Thanks,
Kevin

"Mattias Sjögren" wrote:

> Kevin,
>
> >I assumed that regasm did this for me.
>
> It will only handle normal COM registration (unless you add additional
> code in a ComRegisterFunction). Not the special registration
> requirements for download managers
>
> http://msdn2.microsoft.com/en-us/library/aa7...
>
>
> Mattias
>
> --
> Mattias Sjögren [C# MVP] mattias @ mvps.org
> http://www.msjogren.n... | http://www.dotneti...
> Please reply only to the newsgroup.
>

(Mattias Sjögren)

6/28/2007 8:10:00 PM

0


>Do you have any idea about this? Is there another interface I need to
>implement in order to catch all downloads?

Not a clue, sorry. I'd try asking in one of the IE developer
newsgroups.


Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.n... | http://www.dotneti...
Please reply only to the newsgroup.