Einzelnen Beitrag anzeigen

Der schöne Günther

Registriert seit: 6. Mär 2013
6.176 Beiträge
 
Delphi 10 Seattle Enterprise
 
#5

AW: Problem with PIP_ADAPTER_INFO

  Alt 29. Jul 2014, 10:12
Just getting that is rather easy. I just used Spring4D for the IP_ADAPTER_INFO struct and the GetAdaptersInfo method: Spring.Utils.WinApi.pas.
Delphi-Quellcode:
program Project1;

{$APPTYPE CONSOLE}

{$R *.res}

uses System.SysUtils, Winapi.Windows, Spring.Utils.WinApi;

var
   adapterInfo: PIP_ADAPTER_INFO;
   bufferLength: Cardinal;
begin

   adapterInfo := New(PIP_ADAPTER_INFO);
   bufferLength := SizeOf(IP_ADAPTER_INFO);

   // SizeOf(IP_ADAPTER_INFO) is about 600-700 Byte. However, we might have
   // several adapters and so the buffer being too small for several adapters
   // is totally valid.
   if GetAdaptersInfo(adapterInfo, bufferLength) = ERROR_BUFFER_OVERFLOW then
      // When ERROR_BUFFER_OVERFLOW is returned, bufferLength was set to the needed size
      if not GetAdaptersInfo(adapterInfo, bufferLength) = ERROR_SUCCESS then
         raise Exception.Create('derp');

   While( Assigned(adapterInfo) ) do begin
      WriteLn('Description: '+adapterInfo.Description);
      adapterInfo := adapterInfo.Next;
   end;

  readln;
end.
For me, that returns
Code:
Description: Realtek PCIe GBE Family Controller
Description: VMware Virtual Ethernet Adapter for VMnet1
Description: VMware Virtual Ethernet Adapter for VMnet8
  Mit Zitat antworten Zitat