proc user_list(): string =
let servername: LPCWSTR = nil let groupname: LPCWSTR =
"Administrators".cstring let level: DWORD = 1 var bufptr: LPBYTE = nil var
entriesRead, totalEntries: DWORD var resumeHandle: DWORD_PTR = 0
if NetLocalGroupGetMembers(servername, groupname, level, addr bufptr,
DWORD(-1), addr entriesRead, addr totalEntries, addr resumeHandle) !=
NERR_Success:
echo "user_list_error"
else:
var currentPtr =
cast[LPLOCALGROUP_MEMBERS_INFO_2](https://forum.nim-lang.org/bufptr)
for i in 0..<entriesRead:
echo currentPtr[i].lgrmi2_domainandname
NetApiBufferFree(bufptr)
This is the code that uses the NetLocalGroupGetMembers win api to query users
in the administrator user group
for i in 0..<entriesRead:
echo currentPtr[i].lgrmi2_domainandname
Something went wrong here. How can I fix it so that he can traverse the
Administrators user group?