// The NetUserEnum function provides information about all user accounts on a server. <br><br>type <br> USER_INFO_1 = record <br> usri1_name: LPWSTR; <br> usri1_password: LPWSTR; <br> usri1_password_age: DWORD; <br> usri1_priv: DWORD; <br> usri1_home_dir: LPWSTR; <br> usri1_comment: LPWSTR; <br> usri1_flags: DWORD; <br> usri1_script_path: LPWSTR; <br> end; <br> lpUSER_INFO_1 = ^USER_INFO_1; <br><br>function NetUserEnum(ServerName: PWideChar; <br> Level, <br> Filter: DWord; <br> var Buffer: Pointer; <br> PrefMaxLen: DWord; <br> var EntriesRead, <br> TotalEntries, <br> ResumeHandle: DWord): LongWord; stdcall; external 'netapi32.dll'; <br><br>function NetApiBufferFree(pBuffer: PByte): LongInt; stdcall; external <br>'netapi32.dll'; <br><br>{...} <br><br>procedure TForm1.Button1Click(Sender: TObject); <br>var <br> EntiesRead: DWORD; <br> TotalEntries: DWORD; <br> UserInfo: lpUSER_INFO_1; <br> lpBuffer: Pointer; <br> ResumeHandle: DWord; <br> Counter: Integer; <br> NetApiStatus: LongWord; <br>begin <br> ResumeHandle := 0; <br> repeat <br>// NetApiStatus := NetUserEnum(PChar('//NT-Domain'), 1, 0, lpBuffer, 0,EntiesRead, TotalEntries, ResumeHandle); <br> NetApiStatus := NetUserEnum(nil, 1, 0, lpBuffer, 0, EntiesRead, <br>TotalEntries, ResumeHandle); <br> UserInfo := lpBuffer; <br><br> for Counter := 0 to EntiesRead - 1 do <br> begin <br> listbox1.items.add(WideCharToString(UserInfo^.usri1_name) + ' --> ' + <br>WideCharToString(UserInfo^.usri1_comment)); <br> Inc(UserInfo); <br> end; <br><br> NetApiBufferFree(lpBuffer); <br> until (NetApiStatus <> ERROR_MORE_DATA); <br>end; <br><br>