C++,如何确定 Windows 进程是否正在运行? [英] C++, How to determine if a Windows Process is running?

查看:36
本文介绍了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 进程是否正在运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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