嘿嘿,我自己搞定了,不过COM这东西真烦人,接口之间没有继承关系,无法匿名转换,但是强转却也能转换,
谁能给我一下解释吗?
下面这段代码是可以成功运行的,也是完全满足要求的.
ShellWindows m_IEFoundBrowsers = new ShellWindowsClass();
foreach (InternetExplorer Browser in m_IEFoundBrowsers)
{
if (Browser.Document is HTMLDocumentClass)
{
HTMLDocumentClass doc2 = Browser.Document as HTMLDocumentClass;
HTMLScriptElement script = (HTMLScriptElement)doc2.createElement("script");
script.text = "alert('a');";
HTMLBodyClass body = doc2.body as HTMLBodyClass;
body.appendChild((IHTMLDOMNode)script);
}
}
谁能给我一下解释吗?
下面这段代码是可以成功运行的,也是完全满足要求的.
ShellWindows m_IEFoundBrowsers = new ShellWindowsClass();
foreach (InternetExplorer Browser in m_IEFoundBrowsers)
{
if (Browser.Document is HTMLDocumentClass)
{
HTMLDocumentClass doc2 = Browser.Document as HTMLDocumentClass;
HTMLScriptElement script = (HTMLScriptElement)doc2.createElement("script");
script.text = "alert('a');";
HTMLBodyClass body = doc2.body as HTMLBodyClass;
body.appendChild((IHTMLDOMNode)script);
}
}