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

问题描述

使用Microsoft Spy++,我可以看到属于一个进程的以下窗口:

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

处理 XYZ 窗口句柄,以树形显示,就像 Spy++ 给我的一样:

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

A
  B
  C
     D
E
F
  G
  H
  I
  J
     K

我可以获得进程,并且 MainWindowHandle 属性指向窗口 F 的句柄.如果我使用枚举子窗口,我可以获得 G 到 K 的窗口句柄列表,但我不知道如何找到 A 到 D 的窗口句柄.如何枚举不是 Process 对象的 MainWindowHandle 指定的句柄的子窗口的窗口?

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?

列举我正在使用 win32 调用:

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 获取系统中的每个根窗口句柄.

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

然后您可以通过调用GetWindowThreadProcessId.

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

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

05-28 10:01
查看更多