C ++,如何确定Windows进程是否正在运行? [英] C++, How to determine if a Windows Process is running?
问题描述
这是关于Windows XP进程。
我有一个进程正在运行,我们称之为Process1。 Process1创建一个新的进程Process2,并保存它的id。
现在,Process1希望Process2做一些事情,所以它首先需要确保Process2是仍然存在,并且用户尚未杀死它。
如何检查此过程是否仍在运行?
因为我创建它,我有进程ID,我会认为有一些库函数沿着IsProcessIDValid(id)行,但我不能找到它在MSDN
您可以使用 GetExitCodeProcess
。如果进程仍在运行(或如果它发生以退出代码:()退出,它将返回 STILL_ACTIVE
( 259 p>
This is concerning Windows XP processes.
I have a process running, let's call it Process1. Process1 creates a new process, Process2, and saves its id.
Now, at some point Process1 wants Process2 to do something, so it first needs to make sure that Process2 is still alive and that the user has not not killed it.
How can I check that this process is still running? Since I created it, I have the Process ID, I would think there is some library function along the lines of IsProcessIDValid( id ) but I can't find it on MSDN
You can use GetExitCodeProcess
. It will return STILL_ACTIVE
(259) if the process is still running (or if it happened to exit with that exit code :( ).
这篇关于C ++,如何确定Windows进程是否正在运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!