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 进程是否正在运行?
基础教程推荐
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- CString 到 char* 2021-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
