1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46:
| function TForm1.EnumGroupUsers(lpwServer,lpwGroup: PWideChar): integer; type TNetGroupGetUsersFunction = function(lpwServer,lpwGroup : PWideChar; level : DWORD; pBuffer : Pointer; prefmaxlen : DWORD; entriesread, totalentries, resumeHandle : LongWord): Longint;stdcall; type GROUP_USERS_INFO_0 = record name : PWideChar; end; type TUserGroupArray = array of GROUP_USERS_INFO_0; const PREF_LEN = 1024; var netusers : TNetGroupGetUsersFunction; pBuffer : Pointer; Res,dwRead,dwTotal,hRes,i:Cardinal; Handle: THandle; begin Handle := LoadLibrary('NETAPI32.DLL'); if Handle = 0 then begin Result := GetLastError; Exit; end; @netusers := GetProcAddress(Handle, 'NetGroupGetUsers'); if @netusers = nil then begin Result := GetLastError; Exit; end; hRes:=0; cb.clear; repeat Res:=netusers(lpwServer,lpwGroup,0,pBuffer,PREF_LEN,dwRead,dwTotal,hRes); // An dieser Stelle erhalte ich die EXCEPTION if (Res=0) or (Res=ERROR_MORE_DATA) then begin for i:=0 to dwRead-1 do cb.items.add(TUserGroupArray(pBuffer)[i].name); pBuffer:=NIL; end; until Res<>ERROR_MORE_DATA; FreeLibrary(Handle); end; |