Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / General 2 / September 2004



Tip: Looking for answers? Try searching our database.

Expert required - Building C Browser Helper Object - Calling it and responding to events from VB app

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dave Smithz - 29 Sep 2004 00:25 GMT
Hello there,

Does anyone know whether it is feasible to create a Browser Helper Object
(BHO) in C / C++ (a BHO being a small extension to a web browser like IE
that allows the programmer to monitor and control an instance of a web
browser) that can talk to and pass on events to my VB program?

For example, lets say I wanted to have a BHO that had a function which I
could call from my VB program, and it  would give back to the VB program a
list of all the currently open web browsers URLs. Don't forget that each
browser instance will have an instance of a BHO (I think) and this may add
to the complexity (but correct me if I'm wrong).
I do realise there are other ways of getting lists of the current URL's of
all the browsers, but I need to know using BHO's.

Further to that, (as an example) I would like the BHO to monitor each time
the web surfer pressed a Form button element. I want the BHO to send an
event message to my VB program informing of which instance of browser the
was just pressed, the name of the form button element and some other details
like that.

Is the above scenario feasible? Any help on this matter is greatly
appreciated.

Kind regards

Dave
David Pendrey - 29 Sep 2004 09:15 GMT
I've checked around a bit (research on the net, scanning through available
COM references in VB, etc) and I've not found anything that may do what you
want. Thinking about it I don't see how many web browsers would allow this,
as it would result in a TOTAL lack of privacy for the user. Even if it was a
part of any common browser it would likely be blocked by any virus
scanner/firewall/spyware scanner worth its weight in shrimp. I'd suggest
looking around for a "Internet Explorer COM class" or something like that.
Good luck mate, but I don't like your chances.

> Hello there,
>
[quoted text clipped - 24 lines]
>
> Dave
Dave Smithz - 29 Sep 2004 09:35 GMT
> I've checked around a bit (research on the net, scanning through available
> COM references in VB, etc) and I've not found anything that may do what you
[quoted text clipped - 4 lines]
> looking around for a "Internet Explorer COM class" or something like that.
> Good luck mate, but I don't like your chances.

Hi David and thanks for your comments. I know for a fact that BHO exist. If
you know Google toolbar, this is an BHO.

Take a look at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwebgen/html/b
ho.asp


But it is hard to build one in VB (it can be done, but that is not the
subject of this discussion). My question is about how difficult it would be
to build one in C, that can talk to my VB program. E.g. If the BHO notices a
user click a form button, how can it send that event to my VB program in a
reliable way.

Kind regards

Dave
Frank Adam - 29 Sep 2004 10:20 GMT
>> I've checked around a bit (research on the net, scanning through available
>> COM references in VB, etc) and I've not found anything that may do what
[quoted text clipped - 19 lines]
>user click a form button, how can it send that event to my VB program in a
>reliable way.

It should not be very difficult at all, once you decide on a suitable
exchange mechanism.
For instance..
You can hook a VB form and gather it's messages before the form gets
to them. Then define a value, say, WM_APP + 100, for a particular
message. From WM_APP up to, if i recall, 0xbfff are messages that are
always available to an application.

So if you have defined WM_APP to flag as a URL_CHANGE event (both in
the C app and the VB app of course), then you simply SendMessage that
to your VB app, with lParam pointing to the buffer holding the URL on
the C side. The VB app's custom WindowProc then runs through a switch,
finds that it is a URL_CHANGE event and peels the String out of the
buffer using CopyMemory and sticks it wherever it wants to, then
return False and sinks the message from the Form. Done.

Another way is if your VB app has a Multiline text window, the C side
(after using FindWindow to get a handle to it) then can just send the
message straight to the text window. The Text_Change event should then
trigger and all should be well.

There are other ways too, like using WM_COPYDATA and you could even
cheat and mimic a MouseMove event, but that is getting a bit nasty. :)

Signature

Regards, Frank

mayayana - 29 Sep 2004 17:02 GMT
> I've checked around a bit (research on the net, scanning through available
> COM references in VB, etc) and I've not found anything that may do what you
> want. Thinking about it I don't see how many web browsers would allow this,
> as it would result in a TOTAL lack of privacy for the user.

  Yes. And that's exactly what MS has done with IE. In the
WinXP SP2 update there's apparently an addded feature
to control BHOs and browser Extensions, but other than that
it's a big and well-known problem that the average user is
entirely unaware of. A lot of companies sneak
a BHO onto the machine along with various free software.
(I imagine that's probably how things like Gator work.)
The only way for a user to know about it is to hand-check
in the Registry.

   The BHO then has full access to the IE DOM. IE loads them
automatically as long as the Registry settings are there. BHOs
are typically used for things like targetted adverting, but theoretically
there's no reason that they can't do something like change every
instance of "Kerry" in a page to "Bush", or vice versa.

   BHOs are one of the long list of reasons that one should
not use IE online.
mayayana - 29 Sep 2004 17:09 GMT
This isn't exactly the answer you're asking for but it might help:
  The book Visual Basic Shell Programming by J.P. Hamilton
(O'Reilly) has chapters and source code for both BHOs and
browser extensions. I built an Extension using his code and
it wasn't hard, but it was the kind of thing that you'd never
figure out without sample code. The book also explains how
the whole thing works and provides sample code for accessing
the IE DOM and events.

> Hello there,
>
[quoted text clipped - 23 lines]
>
> Dave
Dave Smithz - 29 Sep 2004 19:06 GMT
"mayayana" <mayaXXyana1a@mindYYspring.com> wrote in message news:x6B6d.7037
> This isn't exactly the answer you're asking for but it might help:
>    The book Visual Basic Shell Programming by J.P. Hamilton
[quoted text clipped - 4 lines]
> the whole thing works and provides sample code for accessing
> the IE DOM and events.

Great stuff, just ordered it. Maybe I will be able to do it in VB after all.
To boot found the book on Amazon market place for £2.99 bargain!
 
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



©2009 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.