Список пользователей в Windows NT/2000
Список пользователей в Windows NT/2000
Список пользователей в Windows NT/2000 unit func; interface uses sysutils, classes, stdctrls, comctrls, graphics, windows; {$externalsym netuserenum} function netuserenum(servername: lpwstr; level, filter: dword; bufptr: pointer; prefmaxlen: dword; entriesread, totalentries, resume_handle: lpdword): dword; stdcall; external 'netapi32.dll' name 'netuserenum'; function netapibufferfree(buffer: pointer{lpvoid}): dword; stdcall; external 'netapi32.dll' name 'netapibufferfree'; procedure getlocaluserlist(ulist: tstringlist); implementation // возвращает список пользователей локального хоста procedure getlocaluserlist(ulist: tstringlist); const nerr_success = 0; filter_temp_duplicate_account = $0001; filter_normal_account = $0002; filter_proxy_account = $0004; filter_interdomain_trust_account = $0008; filter_workstation_trust_account = $0010; filter_server_trust_account = $0020; type tuser_info_10 = record usri10_name, usri10_comment, usri10_usr_comment, usri10_full_name: pwidechar; end; puser_info_10 = ^tuser_info_10; var dweread, dwetotal, dwres, res: dword; inf: puser_info_10; info: pointer; p: pchar; i: integer; begin if ulist = nil then exit; ulist.clear; info := nil; dwres := 0; res := netuserenum(nil, 10, filter_normal_account, @info, 65536, @dweread, @dwetotal, @dwres); if (res <> nerr_success) or (info = nil) then exit; p := pchar(info); for i:=0 to dweread - 1 do begin inf := puser_info_10(p + i * sizeof(tuser_info_10)); ulist.add(widechartostring(pwidechar((inf^).usri10_name))); end; netapibufferfree(info); end; end.