Einzelnen Beitrag anzeigen

Der schöne Günther
Online

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

AW: Problem with PIP_ADAPTER_INFO

  Alt 30. Jul 2014, 18:39
To be honest, I'm really surprised to see some locale string as a device Name. Never seen anything like this. Can you reproduce this on other Computers that also have those names?

In the meantime, let's try GetAdaptersAddresses(..) instead:

Delphi-Quellcode:
program Project1;

{$APPTYPE CONSOLE}
{$R *.res}

uses
   System.SysUtils, // For RaiseLastOSError
   Winapi.IpTypes,
   Winapi.IpHlpApi,
   Winapi.Windows,
   WinApi.WinSock2 // For AF_xxx
;

const
   skipFriendlyName: Boolean = False;
var
   flags: DWORD;
   addresses: PIP_ADAPTER_ADDRESSES;
   buffSize: ULONG;
   returnValue: ULONG;
begin
   flags := 0;
   if skipFriendlyName then
      flags := flags or GAA_FLAG_SKIP_FRIENDLY_NAME;

   addresses := new(PIP_ADAPTER_ADDRESSES);
   buffSize := SizeOf(addresses^);

   returnValue := GetAdaptersAddresses(
      AF_UNSPEC, // Return both IPv4 and IPv6 addresses associated with adapters with IPv4 or IPv6 enabled.
      flags,
      nil,
      addresses,
      Addr(buffSize)
   );

   // Buffer to small? buffSize already got changed, just do it again
   if returnValue = ERROR_BUFFER_OVERFLOW then
      returnValue := GetAdaptersAddresses(
         AF_UNSPEC,
         flags,
         nil,
         addresses,
         Addr(buffSize)
      );

   if returnValue <> ERROR_SUCCESS then
      RaiseLastOSError();

   while Assigned(addresses) do begin
      WriteLn('Adapter Name: '+addresses.AdapterName);
      WriteLn('Friendly Name: '+addresses.FriendlyName);
      WriteLn('Description: '+addresses.Description);
      WriteLn(sLineBreak);
      addresses := addresses.Next;
   end;

   Readln;
end.

That gets me
Code:
Adapter Name: {5778C186-FC70-4E1B-91C2-55B230B54B0F}
Friendly Name: LAN-Verbindung
Description: Realtek PCIe GBE Family Controller


Adapter Name: {823AF0FA-25AF-4942-88C2-1048BCF6B989}
Friendly Name: VMware Network Adapter VMnet1
Description: VMware Virtual Ethernet Adapter for VMnet1


Adapter Name: {04B9E40E-82C6-41F7-B365-34C90086AED1}
Friendly Name: VMware Network Adapter VMnet8
Description: VMware Virtual Ethernet Adapter for VMnet8


Adapter Name: {846EE342-7039-11DE-9D20-806E6F6E6963}
Friendly Name: Loopback Pseudo-Interface 1
Description: Software Loopback Interface 1


Adapter Name: {57FBDD6B-EA00-4580-B520-7B5F254236CD}
Friendly Name: isatap.MyFancyCompany.local
Description: Microsoft-ISATAP-Adapter


Adapter Name: {AC3A8F85-921D-4F6A-A213-969C9AFD77BC}
Friendly Name: Teredo Tunneling Pseudo-Interface
Description: Teredo Tunneling Pseudo-Interface


Adapter Name: {16F898BB-DFC0-4C64-A298-55975DAFBCF8}
Friendly Name: isatap.{823AF0FA-25AF-4942-88C2-1048BCF6B989}
Description: Microsoft-ISATAP-Adapter #3


Adapter Name: {860710BE-74C2-4A45-9C0E-6BA4C0E6313C}
Friendly Name: isatap.{04B9E40E-82C6-41F7-B365-34C90086AED1}
Description: Microsoft-ISATAP-Adapter #2

Geändert von Der schöne Günther (30. Jul 2014 um 18:44 Uhr) Grund: Added addresses.Description
  Mit Zitat antworten Zitat