Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / June 2007

Tip: Looking for answers? Try searching our database.

IDownloadManager

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kevin Cochran - 28 Jun 2007 00:44 GMT
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
Mattias Sjögren - 28 Jun 2007 06:37 GMT
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

Signature

Mattias Sjögren [C# MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Kevin Cochran - 28 Jun 2007 15:40 GMT
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 - 28 Jun 2007 18:26 GMT
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/aa753618.aspx

Mattias

Signature

Mattias Sjögren [C# MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Kevin Cochran - 28 Jun 2007 19:42 GMT
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

> Kevin,
>
[quoted text clipped - 7 lines]
>
> Mattias
Mattias Sjögren - 28 Jun 2007 21:10 GMT
>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

Signature

Mattias Sjögren [C# MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Kevin Cochran - 28 Jun 2007 21:06 GMT
> Kevin,
>
[quoted text clipped - 7 lines]
>
> Mattias
Kevin Cochran - 28 Jun 2007 21:08 GMT
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

> Kevin,
>
[quoted text clipped - 7 lines]
>
> Mattias

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.