我试图寻找一段时间,但找不到它。
有没有简单的方法在VB6中检查进程计数?
在vb.net中很简单,例如:If Process.GetProcessesByName("testprocess").Length < 2 Then...等等。
寻找一些简短而简单的东西。
希望有人知道一个简单而简短的方法 :)
WMI可以提供帮助;
Dim objWMIService As Object, items As Object, item As Object, count As Long
Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")
Set items = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'chrome.exe'", , 32)
For Each item In items
'// cant count so loop
count = count + 1
Next
MsgBox count & " instances"
MsgBox count & " instances"
替换为if (instances < 2) Then MsgBox "There's less than two processes!"
- Alex K.