如何通过VB.Net中的processID检查进程状态 [英] How to check the process status by processID in VB.Net

查看:427
本文介绍了如何通过VB.Net中的processID检查进程状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有进程ID,所以我想检查进程是否正在运行。

请帮助我...

解决方案

我已通过以下方法解决了这个问题

这里我正在传递处理此方法将返回true如果id存在,否则为false。我已将此方法转换为VB并且工作正常。



  private   bool  ProcessExists( int  id)
{
return Process.GetProcesses()。Any(x = > x.Id == id);
}





谢谢,

-RG


当您键入 Process时,您是否碰巧通过Intellisense查看。 ??那里有一种名为 GetProcessById 的方法[ ^ ]。


  Dim  pid  As 处理

pid = Process.GetProcessById( 1 我的电脑
如果 pid.Start = True < span class =code-keyword>然后
MessageBox.Show( Office Admin已经在运行! 警告!!!,MessageBoxButtons.OK,MessageBoxIcon 。错误,MessageBoxDefaul tButton.Button2)
e.Cancel = True
结束 如果
结束 Sub


I have process ID, so I want to check whether process is running or not.
Please help me...

解决方案

I have solved this by below method
here I am passing processed this method will return true if id exist otherwise false. I have converted this method to VB and it's working fine.

private bool ProcessExists(int id)
       {
           return Process.GetProcesses().Any(x => x.Id == id);
       }



Thanks,
-RG


Did you happen to look through Intellisense when you typed Process.?? There's a method in there called GetProcessById[^].


Dim pid As Process

            pid = Process.GetProcessById(1, "My-PC")
            If pid.Start = True Then
                MessageBox.Show("The Office Admin is already running!", "Warning !!!", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button2)
                e.Cancel = True
            End If
        End Sub


这篇关于如何通过VB.Net中的processID检查进程状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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