1

我想使用 mshtml 关闭新打开的 Internet Explorer。

我有一个程序,它从不同的 IE 窗口中获取值。使用元素的 Click() 方法调用到每个窗口的导航。处理页面后,我想关闭窗口。

任何人都知道如何使用 Mshtml 关闭窗口。

提前感谢乌尼

4

2 回答 2

1

See the following code...

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. 
}
于 2011-07-30T20:26:50.230 回答
0

简单:获取HWNDfrom IWebBrowser2,然后发送WM_CLOSE.

于 2011-04-29T07:20:58.320 回答