List.ColumnHeaders.Clear
List.ListItems.Clear
List.View=3
List.GridLines=true
List.FullRowSelect=true
List.MultiSelect=false
List.GridLines=true
List.BackColor=&HF7EFE5
List.ForeColor=&H811E07
List.LabelEdit=false
With List.ColumnHeaders
.Add ,,"服务名称"
.Add ,,"显示名称"
.Add ,,"启动类型"
.Add ,,"运行状态"
.Add ,,"当前状态"
.Add ,,"服务类型"
.Add ,,"登录身份"
.Add ,,"服务描述"
.Add ,,"文件路径及参数"
End With
GetSystemServices
Function GetSystemServices()
On Error Resume Next '错误跳过
Dim sa, objService, objComputer,itm
Set objComputer = GetObject("WinNT://.")
Set sa = CreateObject("Shell.Application")
objComputer.Filter = Array("Service")
For Each objService In objComputer
set itm=List.ListItems.Add(,,objService.Name)
itm.SubItems(1)=objService.DisplayName
itm.SubItems(2)=GetStartType(objService.StartType)
itm.SubItems(3)=sa.IsServiceRunning(objService.Name)
itm.SubItems(4)=objService.Status
itm.SubItems(5)=objService.ServiceType
itm.SubItems(6)=objService.ServiceAccountName
itm.SubItems(7)=GetServiceDsc(objService.Name)
itm.SubItems(8)=objService.Path
Next
Set sa = Nothing
End Function
Function GetStartType(num)
Select Case num
Case 2
GetStartType = "自动"
Case 3
GetStartType = "手动"
Case 4
GetStartType = "已禁用"
End Select
End Function
Function GetServiceDsc(strService)
On Error Resume Next
Dim ws
Set ws = CreateObject("WScript.Shell")
GetServiceDsc = ws.RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\" & strService & "\Description")
Set ws = Nothing
End Function
Private Sub List_ColumnClick(ch)
List.SortKey=ch.Index-1
List.Sorted=true
End Sub
Private Sub List_DblClick()
Dim nItems,nSel,i,strInfo
nSel=-1
nItems=List.ListItems.Count
For i=1 To nItems
If List.ListItems.Item(i).Selected=true Then
nSel=i
Exit For
End If
Next
If nSel=-1 Then
Exit Sub
End If
With List.ListItems.Item(i)
str="服务名称:" & .Text & vbCrLf
str=str & "显示名称:" & .SubItems(1) & vbCrLf
str=str & "启动类型:" & .SubItems(2) & vbCrLf
str=str & "运行状态:" & .SubItems(3) & vbCrLf
str=str & "当前状态:" & .SubItems(4) & vbCrLf
str=str & "服务类型:" & .SubItems(5) & vbCrLf
str=str & "登录身份:" & .SubItems(6) & vbCrLf
str=str & "服务描述:" & .SubItems(7) & vbCrLf
Str=str & "文件路径及参数:" & .SubItems(8) & vbCrLf
End With
MsgBox Str,,"服务信息(" & List.ListItems.Item(i).Text & ")"
End Sub
谁能给我解释讲解下~~~~~