IExplorerBrowserEvents Interface


Jeff Gaines

I posted this in the interop group but it's fairly quiet there so hope
that somebody here may be able to help.

I am writing an app for Vista 64 using C Sharp which hosts an
IExplorerBrowser in a control. It is based on an article on The Code
Project (<>) which
is written in unmanaged C++.

I have managed to get an instance of the IExplorerBrowser using
Activator.CreateInstance and I can display it in my control.

I want to trap some events using the IExplorerBrowserEvents Interface but
I am stumped as to how to create an instance of this interface,
Activator.CreateInstance won't play, nor will CoCreateInstance or
SHCoCreateInstance. I have also created a class which implements the
interface but passing a reference to an instance of that class to
IExplorerBrowser.Advise fails.

ATL has a very useful class called CComObject and also CComPtr but they
not available to me in C# / managed code, unless anybody has written an

I did a search of the registry for IExplorerBrowserEvents and it's not in
there, although IExplorerBrowser is. It seems to me that may be important
but my brain is too far gone now to think that through. The C++ example I
down-loaded compiles and runs OK though, so somehow the OS can find this

So can anybody tell what I need to do to create a valid
IExplorerBrowserEvents so that I can trap/pick up the events fired by the

Any advice would be much appreciated :)



Jeff Gaines

On 16/01/2009 in message <[email protected]> Jeff
Gaines wrote:

Any advice would be much appreciated :)


For anybody interested the method that worked was:

Create a class based on IExplorerBrowserEvents (say JExplorerBrowserEvents).
Include a class variable of type IExplorerBrowserEvents in the class (say
In the class declaration do:
m_IExplorerBrowserEvents = (IExplorerBrowserEvents)this;

In the main control tie them together:

int result =
ref m_dwAdviseCookie);

I tried this a million times today - all I had to do in the end was remove
'ref' from the prototype of IExplorerBrowser.Advise and it works. I need
to think through why but I can sleep tonight!


Jul 20, 2009
Reaction score
I was surprised to see that you've been the only one attempting to host IExplorerBrowser in a managed C# application. You've had more success that I have. I get an AccessViolationException both woth SHCoCreateInstance and CoCreateInstance when I try to show an apparently successfully created instance.

Because of this and other difficulties (some insurmountable) I am very reluctantly returning to unmanaged C++ for my application. But I would still be interested in finding out your solution with Activator.CreateInstance. Would be grateful if you outline the steps you took.

David Aspinall

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question