- Programming with Windows Management Instrumentation
- WMI Overview
- Implementing WMI
- Calling the Component
- Adding Some Extras
In order to call the WMIProcCheck.Process component, you may use code like the following to determine if notepad.exe and SQL Server were running on the server "MyServer":
Dim objProc As WMIProcCheck.Process Dim i as integer Set objProc = New WMIProcCheck.Process With objProc .AddProcess "Notepad", "notepad.exe", False, "MyServer" .AddProcess "SQL Server", "mssqlserver", True, "MyServer" End With objProc.CheckProcesses For i = 0 to Ubound(objProc.Processes,2) MsgBox objProc.Processes(0,i), 0, objProc.Processes(2,i) Next i
Note that the array returned by objProc.Processes returns the running state in the third element (ordinal 2) of the array. The sample application in the download package includes a simple UI (shown in Figure 2) for exercising the component.
Exercise the Component. This simple UI allows the user to specify which processes to check, and subsequently shows the results in the list view control.