To enumerate local groups, use this:
'Windows type used to call the Net API
Private Const MAX_PREFERRED_LENGTH As Long = -1
Private Const NERR_SUCCESS As Long = 0&
Private Const ERROR_MORE_DATA As Long = 234&
Private Type LOCALGROUP_INFO_0
lgrpi1_name As Long
End Type
Private Declare Function NetLocalGroupEnum Lib "netapi32" _
(servername As Byte, _
ByVal Level As Long, _
buff As Long, _
ByVal buffsize As Long, _
entriesread As Long, _
totalentries As Long, _
resumehandle As Long) As Long
Private Declare Function NetApiBufferFree Lib "netapi32" _
(ByVal lpBuffer As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" _
Alias "RtlMoveMemory" _
(pTo As Any, uFrom As Any, _
ByVal lSize As Long)
Private Declare Function lstrlenW Lib "kernel32" _
(ByVal lpString As Long) As Long
Private Sub Form_Load()
Command1.Caption = "Enum Local Groups"
With ListView1
.ColumnHeaders.Add , , "Group Name"
.View = lvwReport
.FullRowSelect = True
End With
End Sub
Private Sub Command1_Click()
Dim bServer() As Byte
Dim tmp As String
ListView1.ListItems.Clear
bServer = "\\workstation" & vbNullChar
'required to show server in caption
tmp = bServer
Label1.Caption = GetLocalGroups(bServer) & " local groups found on " & tmp
End Sub