Dim pTemp As System.Diagnostics.Process()
pTemp = System.Diagnostics.Process.GetProcesses()
Dim pTempProcess As System.Diagnostics.Process
For Each pTempProcess In pTemp
Dim sProcessName As String = pTempProcess.ProcessName
Dim sProcessID As Int32 = pTempProcess.Id
'将EXCEL改成你需要检测的程序名,不要加exe
If StrComp("excel", sProcessName, CompareMethod.Text) = 0 Then
Dim pProcessTemp As System.Diagnostics.Process
'得到进程的开始运行时间
Dim sStartTime As String = pTempProcess.StartTime.ToString ( )
pProcessTemp = Process.GetProcessById(sProcessID)
' MessageBox.Show
'pProcessTemp.Kill()
' pProcessTemp.Close()
End If
Next
非原创