简体   繁体   English

C#、C++、WinAPI - 从另一个进程获取 Z0F4137ED1502B5045D6083AA258B5 的编号

[英]C#, C++ , WinAPI - Get Number of windows from another process

It can be answer in C# or C++ or WinAPI (I know how to pInvoke).它可以在 C# 或 C++ 或 WinAPI 中回答(我知道如何 pInvoke)。

What I want to achieve.我想要达到的目标。 I want to get number of windows that are opened by another applicatoin.我想获取由另一个应用程序打开的 windows 的数量。 For example I have Chat application.例如我有聊天应用程序。 I want to get number of windows because I wan't to detect if someone send me message (New incoming message = one more window).我想获取 windows 的号码,因为我不想检测是否有人向我发送消息(新传入消息 = 多一个窗口)。

So in short.所以简而言之。 How to get number of windows opened by another process.如何获取另一个进程打开的 windows 的编号。

If you have the process ID of the other application, here's a possible Windows API way:如果您有其他应用程序的进程 ID,这里有一个可能的 Windows API 方式:

Enumerate all top level windows with the EnumWindows function, using GetWindowThreadProcessId in the callback function to test for main windows belonging to your given process. Enumerate all top level windows with the EnumWindows function, using GetWindowThreadProcessId in the callback function to test for main windows belonging to your given process. From matching main windows you can then continue to enumerate all its child windows with EnumChildWindows .从匹配主 windows 然后您可以继续枚举其所有子 windows 与EnumChildWindows

First, you need a handle to the top-level window.首先,您需要顶级 window 的句柄。 FindWindow() retrieves it if you know the name of the window.如果您知道 window 的名称,则FindWindow()会检索它。

The second step was already explained a number of times on SO:第二步已经在 SO 上解释过很多次了:

.NET (C#): Getting child windows when you only have a process handle or PID? .NET (C#):当你只有一个进程句柄或 PID 时得到子 windows?

How can I get the child windows of a window given its HWND? 鉴于其 HWND,如何获得 window 的子 windows?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Windows中,如何使用C ++或C#在属于另一个进程的窗口中获取突出显示的文本? - In Windows how to get highlighted text in a window that belongs to another process using C++ or C#? 如何访问Windows 8应用程序历史记录? (来自代码c ++ / c#/ winapi) - How to access windows 8 application history? (from code c++/c#/winapi) 使用.Net / C#或WinAPI将现有进程切换到另一个用户? - Switch Existing Process To Another User Using .Net/C# or WinAPI? 从C#调用C ++“ int WINAPI _tWinMain” - calling C++ “int WINAPI _tWinMain” from C# 在C#中获取Windows电源计划/方案(使用WinAPI) - Get Windows power plans/schemes in C# (using WinAPI) VB6 / C ++ WINAPI到C# - VB6/C++ WINAPI to C# 是否可以通过调用AssemblyInstaller来安装用C ++编写的Windows服务(EXE)(使用CreateService WINAPI)。从C#代码安装? - Is it possible to install a windows service(EXE) written in C++(using CreateService WINAPI) by calling assemblyInstaller.Install from a C# code? 通过C#从Winapi的“ net use”中获取状态列 - get status column from “net use” with winapi via C# 从 Linux c# 获取在远程 Windows 机器上运行的进程 - Get a process running on remote windows machine from Linux c# 从“ Windows任务管理器”进程列表中获取项目c# - Get items from “Windows Task Manager” process list c#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM