怎样使用 NetUserEnum(200分)

  • 主题发起人 主题发起人 Tangyong
  • 开始时间 开始时间
T

Tangyong

Unregistered / Unconfirmed
GUEST, unregistred user!
怎样使用 NetUserEnum。特别是参数LPBYTE *Bufptr怎样传入?谢谢!
 
// The NetUserEnum function provides information about all user accounts on a server. <br><br>type <br>&nbsp; USER_INFO_1 = record <br>&nbsp; &nbsp; usri1_name: LPWSTR; <br>&nbsp; &nbsp; usri1_password: LPWSTR; <br>&nbsp; &nbsp; usri1_password_age: DWORD; <br>&nbsp; &nbsp; usri1_priv: DWORD; <br>&nbsp; &nbsp; usri1_home_dir: LPWSTR; <br>&nbsp; &nbsp; usri1_comment: LPWSTR; <br>&nbsp; &nbsp; usri1_flags: DWORD; <br>&nbsp; &nbsp; usri1_script_path: LPWSTR; <br>&nbsp; end; <br>&nbsp; lpUSER_INFO_1 = ^USER_INFO_1; <br><br>function NetUserEnum(ServerName: PWideChar; <br>&nbsp;Level, <br>&nbsp;Filter: DWord; <br>&nbsp;var Buffer: Pointer; <br>&nbsp;PrefMaxLen: DWord; <br>&nbsp;var EntriesRead, <br>&nbsp;TotalEntries, <br>&nbsp;ResumeHandle: DWord): LongWord; stdcall; external 'netapi32.dll'; <br><br>function NetApiBufferFree(pBuffer: PByte): LongInt; stdcall; &nbsp;external <br>'netapi32.dll'; <br><br>{...} <br><br>procedure TForm1.Button1Click(Sender: TObject); <br>var <br>&nbsp; EntiesRead: DWORD; <br>&nbsp; TotalEntries: DWORD; <br>&nbsp; UserInfo: lpUSER_INFO_1; <br>&nbsp; lpBuffer: Pointer; <br>&nbsp; ResumeHandle: DWord; <br>&nbsp; Counter: Integer; <br>&nbsp; NetApiStatus: LongWord; <br>begin <br>&nbsp; ResumeHandle := 0; <br>&nbsp; repeat <br>// &nbsp; &nbsp;NetApiStatus := NetUserEnum(PChar('//NT-Domain'), 1, 0, lpBuffer, 0,EntiesRead, TotalEntries, ResumeHandle); <br>&nbsp; &nbsp; NetApiStatus := NetUserEnum(nil, 1, 0, lpBuffer, 0, EntiesRead, <br>TotalEntries, ResumeHandle); <br>&nbsp; &nbsp; UserInfo := lpBuffer; <br><br>&nbsp; &nbsp; for Counter := 0 to EntiesRead - 1 do <br>&nbsp; &nbsp; begin <br>&nbsp; &nbsp; &nbsp; listbox1.items.add(WideCharToString(UserInfo^.usri1_name) + ' --&gt; ' + <br>WideCharToString(UserInfo^.usri1_comment)); <br>&nbsp; &nbsp; &nbsp; Inc(UserInfo); <br>&nbsp; &nbsp; end; <br><br>&nbsp; &nbsp; NetApiBufferFree(lpBuffer); <br>&nbsp; until (NetApiStatus &lt;&gt; ERROR_MORE_DATA); <br>end; <br><br>
 
后退
顶部