![]() |
Beispielaufruf von NetQueryDisplayInformation
Hi ;-)
Aus meiner ursprünglichen Frage ist inzwischen fertiger Code geworden, um alle Computerconten einer NT-Domäne bzw. eines Active Directory zu bekommen:
Delphi-Quellcode:
Hier ein Beispielaufruf:
type
NET_DISPLAY_MACHINE = record usri2_name : PWideChar; usri2_comment : PWideChar; usri2_flags : Cardinal; usri2_user_id : Cardinal; usri2_next_index : Cardinal; end; PNET_DISPLAY_MACHINE = ^NET_DISPLAY_MACHINE; const NERR_Success = 0; ERROR_MORE_DATA = 234; function NetQueryDisplayInformation(ServerName: PWideChar; Level, Index, EntriesRequested, ReferredMaximumLength: Cardinal; var ReturnedEntryCount: Cardinal; var SortedBuffer: Pointer): Cardinal; stdcall; external 'Netapi32.dll'; function NetApiBufferFree(Buffer : Pointer): Cardinal; stdcall; external 'NETAPI32.dLL'; function ListComputerAccounts(sServerName: PWideChar; Output:TStrings):integer; var total, res, count, index: Cardinal; sBuffer: Pointer; ComputerAccounts: PNET_DISPLAY_MACHINE; begin Output.clear; index := 0; res := 0; repeat res := NetQueryDisplayInformation(sServerName, 2, index, 100, High(Cardinal), total, sBuffer); showmessage(inttostr(res)); if (res = NERR_Success) or (res=ERROR_MORE_DATA) then begin ComputerAccounts := @sBuffer^; while total > 0 do begin Output.Add(StringReplace(String(ComputerAccounts^.usri2_name), '$', '', [rfReplaceAll])); index := ComputerAccounts^.usri2_next_index; Dec(total); inc(ComputerAccounts); end; end; NetApiBufferFree(sBuffer); until res <> ERROR_MORE_DATA; end;
Delphi-Quellcode:
Gruß,
procedure TForm1.Button1Click(Sender: TObject);
begin ListComputerAccounts('\\servername', ListBox1.Items); end; Eicky :hi: |
Alle Zeitangaben in WEZ +1. Es ist jetzt 11:47 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz