Browser Helper Objects

J

JohnFol

I am trying to make use of BHO's (and no not to write spyware). It seems all
articles relate to C++, whereas my background si in VB.Net
I've managed to understand that I need the following i/face defined

<ComVisible(True), InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
Guid("FC4801A3-2BA9-11CF-A229-00AA003D7352")> _

Public Interface IObjectWithSite

Sub SetSite(<MarshalAs(UnmanagedType.IUnknown)> ByVal pUnkSite As Object)

Sub GetSite(ByRef riid As Object, <MarshalAs(UnmanagedType.Interface)> ByVal
ppvSite As Object)

End Interface



But

I have also added the registry entry using the GUID from the assembly.vb
file, but what escapes me is how to have the browser invoke the code so I
can step through / interrogate the value?

Does anyone have a real step by step guid to getting the basics to work
using VB.net?
 
M

Mattias Sjögren

<ComVisible(True), InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
Guid("FC4801A3-2BA9-11CF-A229-00AA003D7352")> _

Public Interface IObjectWithSite

Sub SetSite(<MarshalAs(UnmanagedType.IUnknown)> ByVal pUnkSite As Object)

Sub GetSite(ByRef riid As Object, <MarshalAs(UnmanagedType.Interface)> ByVal
ppvSite As Object)

End Interface

You don't need to mark the interface as ComVisible, but you should use
the ComImport attribute.

The first parameter of GetSite should be a Guid, not an Object. The
second parameter should be passed ByRef.

I have also added the registry entry using the GUID from the assembly.vb
file, but what escapes me is how to have the browser invoke the code so I
can step through / interrogate the value?

I believe the object should be created and called whenever you open a
browser window. But of course, that only works if your interface
declaration is correct.



Mattias
 
J

JohnFol

Mattias, many thanks for the guidence.

Regards


Mattias Sjögren said:
You don't need to mark the interface as ComVisible, but you should use
the ComImport attribute.

The first parameter of GetSite should be a Guid, not an Object. The
second parameter should be passed ByRef.



I believe the object should be created and called whenever you open a
browser window. But of course, that only works if your interface
declaration is correct.



Mattias
 

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

Top