从进程句柄获取进程信息 [英] Getting Process Information from Process Handle

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

问题描述

我需要得到一个外部进程的 PROCESS_INFORMATION 在我的应用程序中使用,我有进程句柄和进程ID,但我不知道如何去关于获取 PROCESS_INFORMATION



我使用C ++(11),Visual Studio 2012在Windows上。任何帮助将非常感激。

解决方案

PROCESS_INFORMATION code> CreateProcess()。那艘船已经航行;该过程已经开始。



让我们专注于你真正想做的事情。要确定进程是否已终止,请首先使用 OpenProcess()获取进程的句柄。你需要你已经有的PID。然后 WaitForSingleObject()会告诉你是否被终止。传递 INFINITE 为第二个参数阻塞,直到进程终止。如果您要轮询,则传递 0 。最后,使用 CloseHandle()清理。


I need to get the PROCESS_INFORMATION of an external process for use in my application, I have the process handle and process ID, but I don't know how to go about getting the PROCESS_INFORMATION out of that.

I'm using C++(11), Visual Studio 2012, running on Windows. Any help would be greatly appreciated.

解决方案

PROCESS_INFORMATION is filled by CreateProcess(). That ship has sailed; the process was already started.

Let's focus on what you really want to do. To find out if a process has terminated, first use OpenProcess() to obtain a handle to the process. You'll need the PID, which you already have. Then WaitForSingleObject() will tell you if it is terminated. Pass INFINITE for the 2nd argument to block until the process terminates. Pass 0 if you want to poll. Finally, use CloseHandle() to clean up.

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆