0

I would like to open a new tab from my BHO done in C#. Process.Start(u) opens a new window, not a tab, and call the default browsers, which might not be IE.

I want to open the new tab to prompt the user to download and install the latest version of the BHO.

Julien
  • 5,729
  • 4
  • 37
  • 60

1 Answers1

3

The correct way to do this from a BHO is to use IWebBrowser2::Navigate2() (doc link) and pass navOpenInNewTab (doc link).

The interop exists at pinvoke.net, so you can probably start with that.

You can get the IWebBrowser2 pointer from your site by following these steps:

  1. QueryInterface() your site for IID_IServiceProvider.
  2. QueryService() the IServiceProvider for SID_STopLevelBrowser, IID_IServiceProvider.
  3. QueryService() the top level IServiceProvider for SID_SWebBrowserApp, IID_IWebBrowser2.

...but I don't know how to do it in C#.

i_am_jorf
  • 53,608
  • 15
  • 131
  • 222
  • Thanks. I did not realize the TargetFrameName can be used to open a new tab: http://msdn.microsoft.com/en-us/library/cc491275%28v=vs.90%29.aspx it is a "native" C# method, no need to do pinvoke – Julien Feb 22 '12 at 00:50
  • By targeting _blank or some such, you may get a new tab, but the user can configure that behavior to some extent, so it may be a new window. – i_am_jorf Feb 22 '12 at 01:05