关闭指定进程
'判断系统是否已经被打开
Dim lnPress() As Process = System.Diagnostics.Process.GetProcessesByName("Liaoning")
If lnPress.Length > 1 Then
MessageBox.Show("您已经打开一个防汛水情值班系统,不能打开多个系统。 ", "系统已经打开", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
Exit Sub
End If
'根据进程名关闭进程
Dim p As Process() = Process.GetProcessesByName(Me.TextBox1.Text)
If p.Length = 0 Then
MsgBox("没有这个进程 ")
Else
For Each pr As Process In p
Try
pr.Kill()
MsgBox("进程" & pr.Id & "已关闭")
Catch ex As Exception
MsgBox("无法关闭进程:" & ex.Message)
End Try
Next
End If
浙公网安备 33010602011771号