Seznam služeb pomocí ADSI

Funkce:
' Pokud zadáte parametr s hodnotou True, vrátí se zobrazované jména služeb,
' jinak se vrací interní jména služeb
' (interní jména pak mohou být použita jako parametry pro jiné routiny)
'
' POZNÁMKA: požaduje referenci na Active DS Type Library
'
' Použití:
'   Dim svr As Variant
'   For Each svr In GetServiceNames()
'      List1.AddItem svr
'   Next


Function GetServiceNames(ByVal DisplayName As Boolean) As Collection

    Dim thisComputer As ActiveDs.IADsComputer
    Dim aService As ActiveDs.IADsService
    Dim sysInfo As New ActiveDs.WinNTSystemInfo
    
    On Error Resume Next
    
    Set thisComputer = GetObject("WinNT://" & sysInfo.ComputerName & _
        ",computer")
    thisComputer.Filter = Array("Service")
   
    Set GetServiceNames = New Collection
    For Each aService In thisComputer
        If DisplayName Then
            GetServiceNames.Add aService.DisplayName
        Else
            GetServiceNames.Add aService.Name
        End If
    Next
End Function

Zpět

Autor: The Bozena