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

查看:50
本文介绍了如何在 .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 给出的示例是 here.

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天全站免登陆