C# 获取IE浏览器句柄
来源:互联网 发布:windows用mac的硬盘 编辑:程序博客网 时间:2024/05/17 22:52
/// <summary> /// 获取指定窗体的标题 /// </summary> /// <param name="WinHandle">窗体句柄</param> /// <param name="Title">缓冲区取用于存储标题</param> /// <param name="size">缓冲区大小</param> /// <returns></returns> [DllImport("User32.dll")] public static extern int GetWindowText(IntPtr WinHandle, StringBuilder Title, int size); /// <summary> /// 用于枚举子窗体是的委托 /// </summary> /// <param name="WindowHandle">窗体句柄</param> /// <param name="num">自定义</param> /// <returns></returns> public delegate bool EnumChildWindow(IntPtr WindowHandle, string num); /// <summary> /// 获取指定窗体的所有子窗体 /// </summary> /// <param name="WinHandle">窗体句柄</param> /// <param name="ec">回调委托</param> /// <param name="name">自定义</param> /// <returns></returns> [DllImport("User32.dll")] public static extern int EnumChildWindows(IntPtr WinHandle, EnumChildWindow ecw, string name);
</pre><pre name="code" class="csharp"> IList<IntPtr> _WindowsList = new List<IntPtr>(); public bool GetWindows(IntPtr p_Handle, int p_Param) { StringBuilder _ClassName = new StringBuilder(255); StringBuilder title = new StringBuilder(255); GetWindowText(p_Handle, title, 255); GetClassName(p_Handle, _ClassName, 255); if (_ClassName.ToString() == "IEFrame") _WindowsList.Add(p_Handle); return true; } /// <summary> /// 枚举窗体 /// </summary> /// <param name="handle"></param> /// <param name="num"></param> /// <returns></returns> private bool EnumChild(IntPtr handle, string num) { StringBuilder title = new StringBuilder(); //StringBuilder type = new StringBuilder(); title.Length = 100; //type.Length = 100; GetWindowText(handle, title, 100);//取标题 //GetClassName(handle, type, 100);//取类型 listBox2.Items.Add(title); return true; } private void btnIEWnd_Click(object sender, EventArgs e) { EnumWindowsProc _Proc = new EnumWindowsProc(GetWindows); EnumWindows(_Proc, 0); if (_WindowsList.Count > 0) { hwnd = _WindowsList[0]; //SetWindowPos(hwnd, -1, 0, 0, 0, 0, 1 | 2); SetForegroundWindow(hwnd); } }
</pre><pre name="code" class="csharp"> private void btnSubWindow_Click(object sender, EventArgs e) { EnumWindowsProc _Proc = new EnumWindowsProc(GetWindows); EnumWindows(_Proc, 0); EnumChildWindow ecw = new EnumChildWindow(EnumChild); for (int k = 0; k < _WindowsList.Count; k++) { IntPtr mainWindowHandle = _WindowsList[k]; EnumChildWindows(mainWindowHandle, ecw, ""); } if (_WindowsList.Count > 0) { hwnd = _WindowsList[0]; SetForegroundWindow(hwnd); } }
</pre><pre name="code" class="csharp">
1 0
- C# 获取IE浏览器句柄
- C# 获取IE浏览器的HTML内容
- C# 获取句柄
- C#获取句柄
- C# 获取句柄
- c# 获取程序句柄
- C# 获取句柄程序
- 在C#应用程序中获取和设置IE浏览器Cookie
- 在C#应用程序中获取和设置IE浏览器Cookie
- 在C#应用程序中获取和设置IE浏览器Cookie
- 在C#应用程序中获取和设置IE浏览器Cookie
- VC浏览器相关的学习(四)(在BHO中获取IE版本以及获取窗体句柄)
- c# 控制IE浏览器
- c# 控制IE浏览器
- C#操作IE浏览器
- C#控制IE浏览器
- ACTIVEX OCX 获取 IE窗口的句柄
- C# 获取 IE 临时文件
- 随机产生的单词文档排序
- spring的aop编程
- 游戏引擎中三大及时光照渲染方法介绍(以unity3d为例)
- Python 列表、元组、字典、字符串
- C++ Builder实现MessageBox拦截
- C# 获取IE浏览器句柄
- 使用fragment在activity中传值的例子
- Gradle 教程
- android studio 导入 eclipse 并上传到svn
- 如何使用struts2搭建web项目
- Android图片加载框架:ImageLoader,Volley,Picasso,Glide,Fresco
- 数据包接收系列 — 下半部实现(软中断)
- 我的青春,我的梦
- WebView中常见问题总结