JBT3000

I am trying to implement my custom download manager in IE 6. However, I can't seem to get IE to recognize the DownloadUI registry value I entered. I have a setup project in my solution that registers my assembly with vsdraCOM and I took the CLSID from the assembly information screen in my project properties (the COM interop project is seperate from the rest of the application). I have 'Make Assembly COM-visible' and 'Register for COM Interop' checked under the project properties.

This is the CLSID I'm entering in the registry: 3d79d0a7-6549-46a7-b415-0d1fcd12242a

Here is my IDownloadManager code:

Code Snippet

namespace jbtComHdl

{

[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,

System.UInt32 dwBindVerb,

System.Int32 grfBINDF,

System.IntPtr pBindInfo,

[MarshalAs(UnmanagedType.LPWStr)]

System.String pszHeaders,

[MarshalAs(UnmanagedType.LPWStr)]

System.String pszRedir,

System.UInt32 uiCP

);

}

/// <summary>

///The class must have a Guid attribute.

/// </summary>

[ComImport, Guid("988934A4-064B-11D3-BB80-00104B35E7F9")]

public class COMcoclass

{

}

class Handler : IDownloadManager

{

//open new dl screen

public void Download (System.Runtime.InteropServices.ComTypes.IMoniker pmk,

System.Runtime.InteropServices.ComTypes.IBindCtx pbc,

System.UInt32 dwBindVerb,

System.Int32 grfBINDF,

System.IntPtr pBindInfo,

[MarshalAs(UnmanagedType.LPWStr)]

System.String pszHeaders,

[MarshalAs(UnmanagedType.LPWStr)]

System.String pszRedir,

System.UInt32 uiCP)

{

System.Windows.Forms.MessageBox.Show("Test");

DownloadMGR.NetLib myNetLib = new DownloadMGR.NetLib();

DownloadMGR.DLType typeofDL = myNetLib.GetDLType(pmk.ToString());

string un = "";

string pw = "";

if (typeofDL == DownloadMGR.DLType.FTP)

{

throw new Exception("oops");

}

long _filesize = myNetLib.GetFileSize(pmk.ToString(), typeofDL, un, pw);

if (_filesize == 0)

{

throw new Exception("File not found.");

}

System.Windows.Forms.FolderBrowserDialog fb = new System.Windows.Forms.FolderBrowserDialog();

System.Windows.Forms.DialogResult SaveFileTo = fb.ShowDialog();

//get file info

string filesize = _filesize.ToString();

DownloadMGR.DLInfo thisDL = new DownloadMGR.DLInfo(filesize, myNetLib.GetFileName(pmk.ToString()), pmk.ToString(), new Uri(pmk.ToString()).AbsolutePath, un, pw, System.IO.Path.GetFullPath(SaveFileTo.ToString()), "0", typeofDL);

string ID = thisDL.SaveDownload(true, "");

thisDL.SaveDownload(true, "");

DownloadMGR.Form1 f1 = new DownloadMGR.Form1();

f1.Activate();

f1.Show();

f1.StartDownload(ID);

}

}

}




Re: Internet Explorer Extension Development Implementing a custom download manager - DownloadUI registry value.

Martin Xie - MSFT

Move it to the forum "Forums Internet Explorer Development Internet Explorer Extension Development" from CLR.

I believe that forum is more appropriate for such issue.

It would better if you offer what you¡¯ve entered into the registry.

Thanks for your understanding!Smile






Re: Internet Explorer Extension Development Implementing a custom download manager - DownloadUI registry value.

ComputerWhiz

Hey. If you happen to figure this out...I'd like to know too. I need to implement a download manager in J#...and there's no good references out there for how IDownloadManager works in .NET....

If I happen to figure anything out...I'll let you know.




Re: Internet Explorer Extension Development Implementing a custom download manager - DownloadUI registry value.

ComputerWhiz

I figured something out. Try putting a constructor in your class that shows a messagebox. I did that, and proved to myself that IE was at least trying to create my object.

I'm guessing the reason why the DLL is never completely opened is either:

1. Maybe an exception is getting thrown somewhere in the DLL.
2. Our IDL implementations for IDownloadManager are not an exact match with the COM implementation.
3. There's something that no one is telling us that is vital to using the IDownloadManager interface.

Let me know if you come up with anything.




Re: Internet Explorer Extension Development Implementing a custom download manager - DownloadUI registry value.

ComputerWhiz

I figured it out! Use this interface definition:

Code Snippet

[ComVisible(true), ComImport]

[Guid("988934A4-064B-11D3-BB80-00104B35E7F9")]

[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]

public interface IDownloadManager

{

[return: MarshalAs(UnmanagedType.I4)]

[PreserveSig]

void Download(

System.Runtime.InteropServices.ComTypes.IMoniker pmk,

System.Runtime.InteropServices.ComTypes.IBindCtx pbc,

[In, MarshalAs(UnmanagedType.U4)] UInt32 dwBindVerb,

[In] Int32 grfBINDF,

ref IntPtr pBindInfo,

[In, MarshalAs(UnmanagedType.LPWStr)] string pszHeaders,

[In, MarshalAs(UnmanagedType.LPWStr)] string pszRedir,

[In, MarshalAs(UnmanagedType.U4)] UInt32 uiCP);

}

Then, for your class, you have to assign a completely new GUID to it:

Code Snippet

[Guid("*****Put new GUID here*****")]

public class DownloadManager : IDownloadManager {

public void Download(IMoniker pmk,

IBindCtx pbc,

UInt32 dwBindVerb,

int grfBINDF,

ref IntPtr pBindInfo,

String pszHeaders,

String pszRedir,

UInt32 uiCP) {

System.Windows.Forms.MessageBox.Show("Extremely great sign...");

}

}

Use the new GUID in the DownloadUI registry key, and you should be all set.





Re: Internet Explorer Extension Development Implementing a custom download manager - DownloadUI registry value.

Martin Xie - MSFT

Thank you for sharing your valuable experience with us here!




Re: Internet Explorer Extension Development Implementing a custom download manager - DownloadUI registry value.

Vinay

Should the new GUID be same as the assembly guid or different. I will appreciate your help.



Re: Internet Explorer Extension Development Implementing a custom download manager - DownloadUI registry value.

ComputerWhiz

I did a different GUID for the class, since the Assembly GUID references the entire assembly, whereas the class GUID references just the download manager class (which is what you want.) Then, use the class GUID for the registry value, and you're all set.

Just in case you need help getting the URL from the IMoniker, here is the code:

Code Snippet



String ieURL = "";
pmk.GetDisplayName(pbc, (IMoniker) null, ieURL);






Re: Internet Explorer Extension Development Implementing a custom download manager - DownloadUI registry value.

ComputerWhiz

FYI: I should mention that I did my implementation in J#...so if any of the code needs to be reworked for C#, sorry about that. I tried to convert it to C# as best as I could before posting it.




Re: Internet Explorer Extension Development Implementing a custom download manager - DownloadUI registry value.

Vinay

Thank you so much for your reply. I tried changing the GUID as instructed but still cant get my downloader to work. I have created a class library project and marked my assembly as "Make assembly COM-visible". Do I need to explicitly register the assembly so that IE can detect Appreciate your help.



Re: Internet Explorer Extension Development Implementing a custom download manager - DownloadUI registry value.

ComputerWhiz

First, try putting a command to show a message box in your constructor, and then see if that pops up. If it does, then IE is at least loading your DLL, and that will narrow it down to the actual download manager method. If not, then double check the GUID's, and make sure that you put it in the current user hive - HKCU (instead of the local machine hive - HKLM). For some reason, I had issues getting it to work with DownloadUI set in the local machine hive.

Let me know how that goes.