How to get a reference to Internet Explorer's window handle in .net

假装没事ソ 提交于 2020-01-02 07:20:23

问题


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");

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.


回答1:


Getting the HWND is as simple as:

IntPtr hwnd = (IntPtr)IE.HWND;


来源:https://stackoverflow.com/questions/40433615/how-to-get-a-reference-to-internet-explorers-window-handle-in-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!