查找程序是否已经运行的三种方法:
查找程序是否已经运行的三种方法:
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