简体   繁体   English

如何从OpenProcess()获取PROCESS_INFORMATION?

[英]How to get PROCESS_INFORMATION from OpenProcess()?

In Windows, I can get PROCESS_INFORMATION via CreateProcess(). 在Windows中,我可以通过CreateProcess()获得PROCESS_INFORMATION。 However, is it possible to get PROCESS_INFORMATION via OpenProcess()? 但是,是否可以通过OpenProcess()获取PROCESS_INFORMATION?

According to the comments, you are actually interested in enumerating the threads within a process. 根据评论,您实际上对枚举进程中的线程感兴趣。 You can do that using the tool help library. 您可以使用工具帮助库执行此操作。 Call CreateToolhelp32Snapshot to create a snapshot of the process. 调用CreateToolhelp32Snapshot以创建进程的快照。 Then enumerate the threads with Thread32First and Thread32Next . 然后使用Thread32FirstThread32Next枚举线程。 MSDN has sample code here: http://msdn.microsoft.com/en-us/library/windows/desktop/ms686852.aspx MSDN在此处提供示例代码: http//msdn.microsoft.com/en-us/library/windows/desktop/ms686852.aspx

This will enumerate the threads in the snapshot, referring to each thread by its ID. 这将枚举快照中的线程,通过其ID引用每个线程。 You then obtain a handle to a thread, should you need it, by calling OpenThread . 然后,如果需要,可以通过调用OpenThread来获取线程的句柄。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM