返回顶部

收藏

检查一个进程是否在运行

更多

不包括的进程名的扩展名。例如,检查时,如果Internet Explorer是开放的,在价值传递“IEXPLORE”作为参数,而不是“IEXPLORE.EXE”。

using System.Diagnostics;

/// <summary>
/// Determines if a process is running on the local machine.
/// </summary>
/// <param name=\"name\">Name of the process; do not include extension.</param>
/// <returns>True if the named process is running, false otherwise.</returns>
public static bool IsProcessRunning(string name)
{
    try
    {
        Process[] localProcesses = Process.GetProcessesByName(name);
        if (localProcesses.Length < 1)
        {
            return false;
        }
        return true;
    }
    catch (InvalidOperationException ex)
    {
        throw;
    }
}
//该片段来自于http://outofmemory.cn

标签:c#,.net,系统

收藏

0人收藏

支持

0

反对

0

»更多 您可能感兴趣的代码
  1. 2014-05-08 13:23:59C#操作cmd by 流云诸葛
  2. 2014-07-13 10:53:27C# 操作windows注册表 by bargain
  3. 2014-07-20 11:09:09c#全局键盘钩子 by did0602
  4. 2014-08-28 11:33:38以编程方式启动Windows服务 by feng157aaa
  5. 2014-10-02 12:37:29安全删除USB by feng157aaa
  6. 2014-10-10 10:13:07C#开发的简单端口转发程序 by feng157aaa
  7. 2014-05-07 13:56:52C#操作注册表辅助类 by Jlinhai
  8. 2014-05-16 09:51:47C#获得父进程PID编号的完整源代码 by 卷毛
  9. 2014-09-23 11:24:18一个用来调用DOS命令的C#操作类 2 by 卷毛
  10. 2014-10-02 12:46:25C#随机100种声音 by dreamit
  11. 2014-11-22 09:52:29C#检查键盘大小写锁定状态 by bargain

发表评论