Hi I am developing a BHO for IE in C#. I want to open a URL in a new Tab when user click's on my extension button.
I am using IOleCommandTarget interface methods to catch the click events. But those methods don't give any object of browser that can be used to call the navigate method. So, have to try other means like the one mentioned below.
public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText)
{
try
{
InternetExplorer ie = null;
SHDocVw.ShellWindows allBrowser = new SHDocVw.ShellWindows();
int browserCount = allBrowser.Count - 1;
while (browserCount >= 0)
{
ie = allBrowser.Item(browserCount) as InternetExplorer;
if (ie != null && ie.FullName.ToLower().Contains("iexplore.exe"))
{
ie.Navigate2(SNXFileNames.ActivationPage, 0x1000);
break;
}
browserCount--;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
return 0;
}
This method works find in development machine but in non-development machine it gives access denied error.
System.UnauthorizedAccessException: Retrieving the COM class factory fro component with CLSID{} failed due to the following error: 80070005 Access is denied.