且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用c#检查进程是否正在运行

更新时间:2023-11-26 20:18:11

可能,这不是正确的名字。

在我的系统上,它是VLC媒体播放器( 32位),但是也找不到它。

我做的是使用调试器:

Probably, it's not the right name.
On my system, it's "VLC media player (32 bit)", but that doesn't find it either.
What I did was use the debugger:
Process[] pname = Process.GetProcesses();

快速查看列表给了我:

And a quick look through the list gave me:

Process[] pname = Process.GetProcessesByName("vlc");
if (pname.Length > 0)
    {
    MessageBox.Show("Process Running");
    }
else
    {
    MessageBox.Show("Process Not running");
    }

给出正确的消息框。