C#如何借助进程描述检查进程是否正在运行? [英] C# how to check whether a process is running or not with the help of process description?

查看:279
本文介绍了C#如何借助进程描述检查进程是否正在运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,



我知道通过名称或PID检查进程是否存在,但在我的场景中,我需要检查进程是否正在运行,流程描述的帮助。

有没有办法或解决办法?



在我的方案中,我必须检测套房是否有Process Name(setup64)和Process Description(Setup Suite Launcher Unicode)的安装程序是否正在运行。如果正在运行,那么我需要等待它退出。



我可以通过名称Setup64检测到该过程但是很可能在某些机器上它可能不是唯一的因为设置是一种通用名称。因此,为了保持唯一性,我需要通过流程描述进行检测。任何想法我怎么能实现这一目标。请帮忙。



我尝试过:



尝试检测过程按名称和PID。

但无法使用流程描述检测

Hello friends,

I know checking the process existence by name or PID, but in my scenario, i need to check the process is running or not, with the help of Process description.
Is there any way or workaround to do this?

In my scenario i have to detect whether a Suite installer by Process Name (setup64) and Process Description (Setup Suite Launcher Unicode) is running or not. If running then i need to wait for it to exit.

I can detect the process by name Setup64 but then chances are there that it may not be unique on some machines as setup is kind of generic name. So to maintain uniqueness i need to detect by Process description. Any idea how can i achieve this. Please help.

What I have tried:

Tried detecting process by name and PID.
But unable to detect using Process description

推荐答案

您不能使用PID,因为它是由系统分配的当你执行这个过程时,很可能每次进程运行时它都是不同的。您不应该使用该描述,因为开发人员可以在执行之间更改。您应该使用可执行文件名称。互联网上有大量的代码说明了如何做到这一点。
You can't use the PID because it's assigned by the system when you execute the process, and therefore it is highly probably that it will be DIFFERENT every time the process runs. You shouldn't use the description, because that could be changed by a developer between executions. You SHOULD use the executable name. There is plenty of code on the internet that illustrates how to go about doing this.


这篇关于C#如何借助进程描述检查进程是否正在运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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