July 23, 2024, 09:52:15 AM


IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!

BHO: User-Agent Changer for IE6

Started by sapero, July 01, 2008, 06:15:40 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


July 01, 2008, 06:15:40 PM Last Edit: July 05, 2008, 08:56:03 AM by sapero
In this example I have created a Browser Helper Object (BHO) that implements ambient properties for Internet Explorer. Only the UserAgent is used here.
When you host webbrowser control in your own application, it is very easy to change the user agent, but not in IE. I had to find and replace method pointer in IE to redirect the Invoke method to my function.

Because my "Internet zone" has very high restrictions (no ocx, javascript ...) I see often the security infobar.
How to disable it? There is a way with registry path, but after this you are forced to click OK on messagebox that says something about restrictions.
I have implemented a checkbox to disable the infobar without registry patching (by single api call CoInternetSetFeatureEnabled) and also disabled MessageBox api by overwriting its code with "return".

Second tool: a checkbox that disables window focusing/bluring by javascript. I did this always by launching external program IeFocusKiller, now this BHO does this automatically.

To change user agent or other options, select "user agent changer" from IE Tools menu, or press F9 hotkey.
The hotkey listener is implemented as separate thread waiting for keyboard state changes, using DirectInput. Because of DirectInput, any hotkey you set will be used to show the configuration box (CTRL+ALT+DEL will work too).

To register this BHO, you'll need administrator privileges. Funny, but BHO must be registered in HKEY_LOCAL_MACHINE.
BTW InfobarKiller was the primary project name. After I got it working, the project has been extended and renamed to user agent changer.

EDIT: the focus killer was in wrong place (SetSite), moved to OnBeforeNavigate


OK, I got it, crashing on codingmonkeys problem solved.

What's new in 1.3:
- configuration dialog is now implemented as additional (registered) class, that exports IOleCommandTarget. Configure.exe has been removed. Please re-register this dll.
- many code changes - more source files, more code to study.
- both checkable options you can apply/undo at any time.