更新时间:2023-10-21 15:06:46
您的枚举窗口,而不是进程。您获取窗口然后获取创建它的过程。当然,这并不是所有的过程,因为不是每个过程都会创建一个窗口。
有一个例子可以完全解释你所说的此处 [ ^ ]。
Your enumerating windows, not processes. Your getting the window then getting the process that created it. Of course, that's not all the process because not every process creates a window.
There's an example that does exactly what you're talking about here[^].
除了解决方案1:
要枚举进程,您可以使用函数Process32First,Process32Next
Process32First功能( Windows) [ ^ ],
Process32Next功能(Windows) [ ^ ]。
有关更多详细信息,请参阅此CodeProject文章:枚举过程:一种实用的方法 [ ^ ]。-SA
In addition to Solution 1:
To enumerate processes, you can use use the functionsProcess32First, Process32Next
Process32First function (Windows)[^],
Process32Next function (Windows)[^].
See also this CodeProject article for further detail: Enumerating processes : A practical approach[^].—SA
使用此代码:
Use this code:
HANDLE hProcessSnap;
HANDLE hProcess;
PROCESSENTRY32 pe32;
DWORD dwPriorityClass;
// Take a snapshot of all processes in the system.
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);