我想使用mshtml(c#代码)关闭新打开的Internet Explorer窗口。 我使用带有Ie实例的Mshtml并浏览了一个url并点击了一个链接。点击链接后,我将在新窗口中打开文档。我想知道有没有办法从新打开的窗口获取值,并在获取值关闭窗口后..
提前致谢....
乌尼
答案 0 :(得分:1)
请参阅以下代码......
using System.Runtime.InteropServices;
// IE can be found in COM library called
// Microsoft Internet Controls:
using IE = SHDocVw.InternetExplorer;
static void OpenAndCloseIE()
{
// Get an instance of Internet Explorer:
Type objClassType = Type.GetTypeFromProgID("InternetExplorer.Application");
var instance = Activator.CreateInstance(objClassType) as IE;
// Close Internet Explorer again:
instance.Quit();
// Release instance:
System.Runtime.InteropServices.Marshal.ReleaseComObject(instance);
instance = null; // Don't forget to unreference it.
}