AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Win32/Win64 API (native code) Delphi Beispielaufruf von NetQueryDisplayInformation
Thema durchsuchen
Ansicht
Themen-Optionen

Beispielaufruf von NetQueryDisplayInformation

Ein Thema von eicky · begonnen am 23. Jun 2006
Antwort Antwort
eicky
(Gast)

n/a Beiträge
 
#1

Beispielaufruf von NetQueryDisplayInformation

  Alt 23. Jun 2006, 08:43
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:
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;
Hier ein Beispielaufruf:

Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
begin
  ListComputerAccounts('\\servername', ListBox1.Items);
end;
Gruß,

Eicky
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:46 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz