Moin Zusammen,
nur um mal zu verdeutlichen, wie's so bei mir aussieht (speziell wegen des @pBuffer)
Delphi-Quellcode:
procedure TfrmMAIN.Button1Click(Sender: TObject);
var
pBuffer : PUSER_INFO_0;
pWork : PUSER_INFO_0;
dwEntriesRead : DWORD;
dwTotalEntries : DWORD;
i : integer;
begin
if NetUserEnum(nil,0,FILTER_NORMAL_ACCOUNT,@pBuffer,MAX_PREFERRED_LENGTH,@dwEntriesRead,@dwTotalEntries,nil) = NERR_Success then
begin
try
ListBox1.Items.Clear;
pWork := pBuffer;
for i := 1 to dwEntriesRead do
begin
ListBox1.Items.Add(pWork.usri0_name);
inc(pWork);
end;
finally
NetApiBufferFree(pBuffer);
end;
end;
end;
Unter Verwendung dieser Deklarationen:
Delphi-Quellcode:
type
// LMCons.h
NET_API_STATUS = DWORD;
// aus LMACCESS.H
PUSER_INFO_0 = ^USER_INFO_0;
USER_INFO_0 =
packed record
usri0_name : PWChar;
end;
PUSER_INFO_1 = ^USER_INFO_1;
USER_INFO_1 =
packed record
usri1_name : PWChar;
usri1_password : PWChar;
usri1_password_age : DWord;
usri1_priv : DWord;
usri1_home_dir : PWChar;
usri1_comment : PWChar;
usri1_flags : DWord;
usri1_script_path : PWChar;
end;
const
MAX_PREFERRED_LENGTH = DWORD(-1);
FILTER_NORMAL_ACCOUNT = $0002;
// LMERR.H
NERR_Success = 0; // Success
// aus LMACCESS.H
function NetUserEnum(
const servername : PWChar;
const level : DWord;
const filter : DWord;
const bufptr : Pointer;
const prefmaxlen : DWord;
const entriesread : PDWord;
const totalentries : PDWord;
const resume_handle : PDWord
) : NET_API_STATUS; stdcall; external 'netapi32.dll';
// aus LMAPIbuf.h
function NetApiBufferFree(
const Buffer : Pointer
) : NET_API_STATUS; stdcall; external 'netapi32.dll';