我如何判断一个进程是否不是 运行?

How can I tell if a process is not running?

好吧,我已经在这个问题上坚持了 2 天,持续 3 天,但我仍然想不出办法。我需要用它来判断资源管理器是否 运行 如果不启动它,我需要这样做的原因是制作一个程序来防止人们泄漏文件......刚刚整理了其余代码坚持这个。我能想到的唯一效率不高的方法是将所有进程添加到列表框中并搜索资源管理器,如果不存在,则启动资源管理器。非常感谢您的帮助:)

Dim sExplorerName As String = "explorer"
Dim oProcessList() As Process
Dim bFound As Boolean = False

' Get a list of all running processes

oProcessList = Process.GetProcesses()

' Check each process to see if it is explorer

For Each oProc As Process In oProcessList
    If (sExplorerName = oProc.ProcessName) Then
        ' We found the explorer process
        bFound = True
    End If
Next oProc

If bFound = False Then
    ' Start explorer.exe since it was not found to be running
    Process.Start(System.IO.Path.Combine(System.Environment.GetEnvironmentVariable("windir"), "explorer.exe"))
End If