这是得到进程,打开和关闭进程的.
Public Function CheckAlive(ByVal proName As String) As Boolean
Dim temProc As Process
CheckAlive = True
processes = Process.GetProcessesByName(proName)
For i As Int16 = 0 To processes.Length
If processes(0).Responding Then
End If
Next
If processes.Length = 0 Then
Return False
End If
End Function
打开进程
Public Overloads Sub LaunchProc(ByVal docPath As String)
Dim myProcess As New Process
Try
myDocPath = docPath
myProcess.StartInfo.FileName = myDocPath
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal
myProcess.Start()
myProcess.WaitForInputIdle()
Catch ex As Exception
Throw New Exception("The file doesn't exist.")
End Try
End Sub
关闭进程
Public Overloads Sub CloseProcess(ByVal proID As Integer)
Dim tempProc As Process
Try
tempProc = Process.GetProcessById(proID)
tempProc.CloseMainWindow()
tempProc.WaitForExit()
Catch ex As System.NullReferenceException
Throw New Exception("No instances of " & proID & " running.")
End Try
End Sub