Hi,
I've written some code to attempt to get the selected text from an HTML
document loaded in a running instance of IE. I need to be able to
access the frames collection of the IHTMLDocument2 interface so that I
can get text from the documents contained in the frames.
Here's what I've got:
using SHDocVw;
using mshtml;
ShellWindows m_IEFoundBrowsers = new ShellWindowsClass();
foreach (InternetExplorer Browser in m_IEFoundBrowsers)
{
if ((int)win.Window == Browser.HWND)
{
m_IE = Browser as InternetExplorer;
browserExists = true;
break;
}
}
if (!browserExists)
{
return;
}
IWebBrowser2 doc = m_IE as IWebBrowser2;
IHTMLDocument2 hdoc = doc.Document as IHTMLDocument2;
int frameNum = hdoc.frames.length;
The problem is, I get "Class not registered (Exception from HRESULT:
0x80040154 (REGDB_E_CLASSNOTREG))"}
System.SystemException {System.Runtime.InteropServices.COMException
on the final line, on the attempt to access the frames collection. This
works fine on Windows 2000, but this error occurs on Windows XP. How
can this class not be registered? Should I obtain the interface some
other way, without using SHDocVw?
Any help much appreciated!
Phil
PhilC - 18 Nov 2006 17:37 GMT
I've managed to get this working now but without requiring the frames
collection (by using IHtmlDocument2.ActiveElement, extracting the
IWebBrowser2 interface, and getting the internal document out that
way).
I'd still be curious to know why the frames collection was inaccessible
though.
Thanks
> Hi,
>
[quoted text clipped - 38 lines]
>
> Phil