C++, How to determine if a Windows Process is running?(C++,如何确定 Windows 进程是否正在运行?)
问题描述
这与 Windows XP 进程有关.
This is concerning Windows XP processes.
我有一个进程正在运行,我们称之为 Process1.Process1 创建一个新进程 Process2,并保存其 id.
I have a process running, let's call it Process1. Process1 creates a new process, Process2, and saves its id.
现在,在某些时候 Process1 希望 Process2 做某事,所以它首先需要确保 Process2 仍然活着并且用户没有杀死它.
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.
如何检查此进程是否仍在运行?因为我创建了它,所以我有进程 ID,我认为有一些库函数与 IsProcessIDValid( id ) 类似,但我在 MSDN 上找不到它
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
推荐答案
您可以使用 GetExitCodeProcess
.如果进程仍在运行(或者它碰巧以该退出代码退出:(),它将返回 STILL_ACTIVE
(259).
这篇关于C++,如何确定 Windows 进程是否正在运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:C++,如何确定 Windows 进程是否正在运行?


- 从python回调到c++的选项 2022-11-16
- 如何对自定义类的向量使用std::find()? 2022-11-07
- STL 中有 dereference_iterator 吗? 2022-01-01
- 静态初始化顺序失败 2022-01-01
- Stroustrup 的 Simple_window.h 2022-01-01
- 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01
- 使用/clr 时出现 LNK2022 错误 2022-01-01
- C++ 协变模板 2021-01-01
- 近似搜索的工作原理 2021-01-01
- 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01