C# 如何枚举进程中的所有窗口?

C# 如何枚举进程中的所有窗口?,c#,windows,process,C#,Windows,Process,我需要捕获第三方进程的特定窗口。我可以找到Process.MainWindowHandle作为主窗口句柄,但我可以使用什么来列出其他窗口 我正在使用C#/.NET该函数可能会帮助您。子窗口也可以有子窗口等等 还有 这里的另一篇文章提供了更多细节:第三方应用程序启动了其他窗口,而不是子窗口 使用VisualStudio附带的Spy++工具可以找出什么是结构 在此之后,我能够使用WindowClassName(取自Spy++)使用FindWindowEx函数找到必要的窗口: lastWindows=

我需要捕获第三方进程的特定窗口。我可以找到Process.MainWindowHandle作为主窗口句柄,但我可以使用什么来列出其他窗口

我正在使用C#/.NET

该函数可能会帮助您。子窗口也可以有子窗口等等

还有


这里的另一篇文章提供了更多细节:

第三方应用程序启动了其他窗口,而不是子窗口

使用VisualStudio附带的Spy++工具可以找出什么是结构

在此之后,我能够使用WindowClassName(取自Spy++)使用FindWindowEx函数找到必要的窗口: lastWindows=FindWindowEx(IntPtr.Zero,lastWindows,m.WindowClassName,null)

使用Win32 API(如果需要)

然后使用Win32 API检查每个窗口属于哪个进程


谢谢你的名字-我会在问题解决的时候结束这个问题
[DllImport("user32.dll", CharSet=CharSet.Auto, SetLastError=true)]
public static extern bool EnumWindows(EnumThreadWindowsCallback callback, IntPtr extraData);
[DllImport("user32.dll", CharSet=CharSet.Auto, SetLastError=true)]
public static extern int GetWindowThreadProcessId(HandleRef handle, out int processId);