如何在.net中获得对Internet Explorer窗口句柄的引用 [英] How to get a reference to Internet Explorer's window handle in .net

查看:113
本文介绍了如何在.net中获得对Internet Explorer窗口句柄的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,我正在尝试获取一直使用C#自动化的Internet Explorer实例的HWND。

Basically I am trying to get the HWND of an instance of Internet Explorer that I have been automating in C#.

        SHDocVw.InternetExplorer IE = new SHDocVw.InternetExplorer();
        IE.AddressBar = false;
        IE.MenuBar = false;
        IE.OnQuit += IE_OnQuit;
        IE.Visible = true;
        IE.Navigate2("www.bing.com");

我想引用它的窗口句柄以进行进一步的操作,但是唯一的例子要做到这一点是在C ++中,我不确定如何在C#中做类似的事情。 msdn提供的示例是此处

I would like to get a reference to it's window handle for further manipulation, however the only example of how to do this is in C++ and I am not sure how to do something similar in C#. The Example the msdn gave is here.

推荐答案

获取HWND很简单:

IntPtr hwnd = (IntPtr)IE.HWND;

这篇关于如何在.net中获得对Internet Explorer窗口句柄的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆