检查开放进程,如果开放,则将其杀死 [英] Checking for open processes, if it's open, kill it

查看:57
本文介绍了检查开放进程,如果开放,则将其杀死的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在尝试添加此功能,以检查打开的进程并在这种情况下将其杀死.这是我到目前为止的内容:

Hi everyone,

I''m trying to add this functionality of checking for open processes and killing it if that is the case. This is what I have so far:

Process[] open_procs = Process.GetProcessesByName("PicoScope.exe");
if (open_procs.Length > 0)
{
   open_procs.Kill();
}


在可用的open_procs命令中找不到Kill命令.


It''s not finding the Kill command within the open_procs available commands. Can someone shed some light as to how I can proceed with this?

推荐答案

您正在尝试杀死进程数组,而不是单个进程本身.
您需要像这样遍历它们.
You are trying to kill the array of processes, rather than the individual processes themselves.
You need to loop through them like this.
Process[] open_procs = Process.GetProcessesByName("PicoScope.exe");
if( open_procs.Length > 0 )
{
   foreach( var proc in open_procs )
   {
      proc.Kill();
   }
}


这篇关于检查开放进程,如果开放,则将其杀死的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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