查找程式是否已經運行的三種方法:
1.
If Ubound(Diagnostics.Process.GetProcessesByName(Diagnostics.Process.GetCurrentProcess.ProsseName))>0 then
messagebox.show("程式正在運行!")
end if
2.
Dim ps As new Process
For Each ps In Diagnostics.Process.GetProcesses
If pro.ProcessName = "行程名稱" Then
messagebox.show("程式正在運行!")
End If
Next
3.
'寫一個功能。
Function FindProcess(ProcessName) As Boolean
Dim ps
'列舉行程
For Each ps In GetObject("winmgmts:\\.\root\cimv2:win32_process").instances_ '回圈行程
If UCase(ps.Name) = UCase(ProcessName) Then
FindProcess = True
Exit Function
End If
Next
End Function
,=以下呼叫程序
If FindProcess("xxxx.exe") Then '在此修改為你要找的程式名
MsgBox.show ("該程式正在運行!")
Else
MsgBox .show("該程式不正在運行!")
End If
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/21174.html
標籤:VB.NET
下一篇:詳說tcp粘包和半包
