Internet Explorer IDownloadManager COM interface

  • Thread starter Thread starter petar petrov via DotNetMonster.com
  • Start date Start date
P

petar petrov via DotNetMonster.com

Hi to all,
I need to implement the above interface in C#.NET managed application.
Since I am a noob with COM i looked at MSDN article of how to invoke COM from inside managed code. However the article require COM object (.dll) i fail to find for internet Explorer.

Plese can someone explain in details ho to go through!?
 
I have the following:

using System;
using System.Runtime.InteropServices;

/*
I have the following IDL for IDownloadManager:

interface IDownloadManager;
[
helpstring("IDownloadManager interface"),
object,
uuid(988934A4-064B-11D3-BB80-00104B35E7F9), // IID_IDownloadManager
pointer_default(unique),
local
]
interface IDownloadManager : IUnknown
{
HRESULT Download(
[in] IMoniker *pmk, // Identifies the object to be downloaded
[in] IBindCtx *pbc, // Stores information used by the moniker to bind
[in] DWORD dwBindVerb, // The action to be performed during the bind
[in] LONG grfBINDF, // Determines the use of URL encoding during the bind
[in] BINDINFO *pBindInfo, // Used to implement IBindStatusCallback::GetBindInfo
[in] LPCOLESTR pszHeaders, // Additional headers to use with IHttpNegotiate
[in] LPCOLESTR pszRedir, // The URL that the moniker is redirected to
[in] UINT uiCP // The code page of the object's display name
);
};
*/


namespace COMInterop
{

[ComImport, GuidAttribute("988934A4-064B-11D3-BB80-00104B35E7F9"),
InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown),ComVisible(false)]
public interface IDownloadManager
{
void Download(
System.Runtime.InteropServices.UCOMIMoniker pmk,
System.Runtime.InteropServices.UCOMIBindCtx 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>
/// Summary description for COMcoclass.
/// The class must not inherit from any other class.
///The class must implement no interfaces.
///The class must also have a Guid attribute that sets the globally unique identifier (GUID) for the class.
/// </summary>
[ComImport, Guid("988934A4-064B-11D3-BB80-00104B35E7F9")]
public class COMcoclass //cannot inherit anything
{
// Cannot have any members here
// NOTE that the C# compiler will add a default constructor
// for you (no parameters).
}
}



Then i have in the main:

class MainClass
{

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// Create an instance of a COM coclass - calls
//
// CoCreateInstance(E436EBB3-524F-11CE-9F53-0020AF0BA770,
// NULL, CLSCTX_ALL,
// IID_IUnknown, &f)
//
// returns null on failure.
//
try
{
//create instance of the co class
COMcoclass MyCOM = new COMcoclass();

// QueryInterface for the IDownloadManager interface:
IDownloadManager dm = (IDownloadManager)MyCOM;


}
catch(Exception ex)
{
Console.WriteLine("Unexpected COM exception: " + ex.Message);
Console.ReadLine();
}

}

}





everything compiles fine,
but i have at runtime: unexpected COM exception COM object with CLSID(the guid number) is either nor registered or not valid.
 
Back
Top