我想使用 mshtml 关闭新打开的 Internet Explorer。
我有一个程序,它从不同的 IE 窗口中获取值。使用元素的 Click() 方法调用到每个窗口的导航。处理页面后,我想关闭窗口。
任何人都知道如何使用 Mshtml 关闭窗口。
提前感谢乌尼
我想使用 mshtml 关闭新打开的 Internet Explorer。
我有一个程序,它从不同的 IE 窗口中获取值。使用元素的 Click() 方法调用到每个窗口的导航。处理页面后,我想关闭窗口。
任何人都知道如何使用 Mshtml 关闭窗口。
提前感谢乌尼
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.
}
简单:获取HWND
from IWebBrowser2
,然后发送WM_CLOSE
.