Umm thanks? Ok to those of you who want to know how to do this, here is a little program I wrote when I found out how to do it.
-
Dim WinProcesses() As String
-
Dim WinProc As Object
-
Dim WinProcSet As Object
-
Dim WinProcCount As Long
-
Dim CheckLoop As Long
-
Private Sub cmdnotepad_Click()
-
GetProcesses
-
For CheckLoop = 1 To WinProcCount
-
If WinProcesses(CheckLoop) = "notepad.exe" Then
-
MsgBox "Notepad is running!"
-
Exit Sub
-
End If
-
Next CheckLoop
-
MsgBox "Notepad is not running!"
-
End Sub
-
Private Sub GetProcesses()
-
WinProcCount = 0
-
'Count the processes to redim the array
-
Set WinProcSet = GetObject("WinMgmts:").execquery("select * from Win32_process")
-
For Each WinProc In WinProcSet
-
WinProcCount = WinProcCount + 1
-
Next
-
-
'Create the process list in an array
-
ReDim WinProcesses(1 To WinProcCount) As String
-
WinProcCount = 0
-
For Each WinProc In WinProcSet
-
WinProcCount = WinProcCount + 1
-
WinProcesses(WinProcCount) = WinProc.Name
-
Next
-
End Sub
-
If it's possible to check an array for a value without running a processor unfriendly loop, I'd like to know that if you don't mind.