AndreyIl » 03.11.2005 (Чт) 9:33
На форме создаешь CommandButton (Command1) и 3 ListBox(List1 - имя процесса, List2 - под кем запущен процесс, List3 - домен). Вот код:
Option Explicit
Private WMIService As Object
Private ProcessList As Object
Private Process As Object
Private Prop As String
Private UserName As String
Private Domain As String
Private Sub Command1_Click()
Refr
End Sub
Private Sub Form_Load()
Set WMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\.\root\cimv2")
Refr
End Sub
Private Sub List1_DblClick()
If MsgBox("Вы действительно хотите убить процесс?", vbYesNo, "Убиение процесса") = vbNo Then Exit Sub
Set ProcessList = WMIService.ExecQuery _
("Select * from Win32_Process Where Name = '" & List1.List(List1.ListIndex) & "'")
For Each Process In ProcessList
Process.Terminate
Next
Refr
End Sub
Private Sub Refr()
List1.Clear
List2.Clear
List3.Clear
Set ProcessList = WMIService.ExecQuery _
("Select * from Win32_Process")
For Each Process In ProcessList
UserName = ""
Domain = ""
If Process.Name <> "System Idle Process" Then
If Process.Name <> "System" Then
If Process.Name <> "csrss.exe" Then
Prop = Process.GetOwner(UserName, Domain)
List1.AddItem Process.Name, List1.ListCount
Else
List1.AddItem "csrss.exe", List1.ListCount
End If
Else
List1.AddItem "System", List1.ListCount
End If
Else
List1.AddItem "System Idle Process", List1.ListCount
End If
List2.AddItem UserName, List2.ListCount
List3.AddItem Domain, List3.ListCount
Next
End Sub