获取所有窗口句柄的过程 [英] Get all window handles for a process

查看:274
本文介绍了获取所有窗口句柄的过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用微软间谍++,我可以看到,属于一个进程如下窗口:

工艺XYZ窗口句柄,在树的形式,就像间谍++显示给我:

  A
  乙
  C
     ð
Ë
F
  G
  H
  一世
  Ĵ
     ķ
 

我能得到这个过程中,和MainWindowHandle属性指向句柄窗口F.如果使用的是我能得到窗口的列表句柄至K G I枚举子窗口,但我无法弄清楚如何找到窗口句柄A至D。我怎么能枚举窗口不由MainWindowHandle指定的进程对象的句柄的孩子?

要列举我使用的是Win32调用:

  [System.Runtime.InteropServices.DllImport(strUSER32DLL)
            公共静态外部INT EnumChildWindows(IntPtr的的HWND,WindowCallBack pEnumWindowCallback,INT iLParam);
 

解决方案

IntPtr.Zero 的hWnd 来让每根窗口句柄在系统中。

您可以再通过调用<一个检查Windows的所有者过程href="http://msdn.microsoft.com/en-us/library/ms633522%28v=VS.85%29.aspx"><$c$c>GetWindowThreadProcessId.

Using Microsoft Spy++, I can see that the following windows that belong to a process:

Process XYZ window handles, displayed in tree form just like Spy++ gives me:

A
  B
  C
     D
E
F
  G
  H
  I
  J
     K

I can get the process, and the MainWindowHandle property points to the handle for window F. If I enumerate the child windows using I can get a list of window handles for G through K, but I can't figure out how to find the window handles for A through D. How can I enumerate windows that are not children of the handle specified by MainWindowHandle of the Process object?

To enumerate I'm using the win32 call:

[System.Runtime.InteropServices.DllImport(strUSER32DLL)]
            public static extern int EnumChildWindows(IntPtr hWnd, WindowCallBack pEnumWindowCallback, int iLParam);

解决方案

Pass IntPtr.Zero as hWnd to get every root window handle in the system.

You can then check the windows' owner process by calling GetWindowThreadProcessId.

这篇关于获取所有窗口句柄的过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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