Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create Internet Explorer sidebar extension in C#?

I want to create an IE extension - a sidebar ("Explorer bar") looking just like bookmarks/favourites sidebar in IE9, it is supposed to show HTML webpage in it.

I googled for a few hours, read some:

  • http://msdn.microsoft.com/en-us/library/bb776819.aspx (yikes!),
  • http://msdn.microsoft.com/en-us/library/aa753587.aspx,
  • http://www.codeproject.com/KB/shell/Attach_BHO_with_C_.aspx

and

  • How to get started with developing Internet Explorer extensions?

but I need a sidebar - no windows or message boxes. I'd like to see a simple, basic solution - I'll do the details later.

I've created an extension for FF and Chrome - their Extension Dev Centers are much better than Microsoft's.

Please, tell me what should I do in simple steps. I want to create the IE extension in Visual Studio 2010 and C#. There's no way I'll create it in C++.

EDIT (2011-10-20):

I've managed to accomplish the solution in How to get started with developing Internet Explorer extensions? but:

  1. it does not work correctly: the set word does not get highlighted at all,
  2. I think that the problem is that I use IE9 not 8,
  3. the solution does not tell me how to create a sidebar for IE9.

BTW. I Use Visual Studio 2010 Express (Visual C# 2010 Express) - not Professional or Ultimate - I think there's no Start External Program option in Debug tab of the Project.

PLEASE help.

like image 403
pinus.acer Avatar asked Oct 19 '11 12:10

pinus.acer


1 Answers

I've found a perfect working example: http://code.msdn.microsoft.com/CSIEExplorerBar-ba8fe182/view/Reviews

It's very interesting that I couldn't find it with Google...

After downloading just extract the file and open CSIEExplorerBar.sln. Some of the solution's projects cannot be imported into VS 2010 - it's just installer projects, you don't need them to run the BHO.

Go to project's properties and in Build Events tab put this text into "Post-build event command line" (literally):

"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\gacutil.exe" /f /i "$(TargetDir)$(TargetFileName)"

"C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe" /unregister "$(TargetDir)$(TargetFileName)"

"C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe" "$(TargetDir)$(TargetFileName)"

Build the project - you get errors because, as you can see, the second command tries to unregister the BHO but nothing is registered yet. You can re-run the build and you'll get no errors.

Open the IE. Open View Menu, Explorer Bars and click "Image List Explorer Bar" - you should see the explorer bar you've just built!

To allow your BHO showing the HTML page you just need to change the User Control design - add the WebBrowser control and add the URL of the page to show to the control.

Details

I've created extensions for Chrome and Firefox. IE extensions are the ones of the worst architecture. The documentation is horrible - it's outdated and mosty for C++ only. Extensions for Chrome and Firefox are HTML/XUL and JavaScript based - almost every web developer can build his/hers own extension in minutes! I think it's much much harder in IE - you have to literally EXPLORE the internet to find any information that is useful about this technology.

As you can read here - http://msdn.microsoft.com/en-us/library/bb776819.aspx - you have to play with magical thing called Registry. It's really the worst thing they could choose to store data about extensions. I still don't know where should I add the information about the author or the version of the BHO. If you do please answer: https://stackoverflow.com/questions/7926800/how-to-add-author-name-version-number-description-etc-to-browser-helper-objec

The BHO won't work if it's not signed with a key - IEExplorerBar.snk in this solution. You can add a key in a new project very easily - just open the project properties, "Signing" tab - "Sign the assembly" and add the new key.

The documentation is very very old and nobody does anything about it!

IMHO Microsoft should redesign and write IE again - it's architecture is outdated, anachronic.

Some links

Adding toolbar buttons to open your explorer bar: http://msdn.microsoft.com/en-us/library/aa753588%28v=VS.85%29.aspx#details_explorer

Some information about registry in x64 systems: http://msdn.microsoft.com/en-gb/library/aa384232%28VS.85%29.aspx

About Interlop namespace (SHDocVw): http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.ole.interop.aspx

like image 90
pinus.acer Avatar answered Oct 11 '22 14:10

pinus.acer