Einzelnen Beitrag anzeigen

quendolineDD

Registriert seit: 19. Apr 2007
Ort: Dresden
781 Beiträge
 
Turbo Delphi für Win32
 
#7

Re: IP-ADAPTER_ADDRESS Structure

  Alt 16. Nov 2008, 22:10
Alles klar. Habs nun soweit alles was zur GetAdaptersAddresses Function dazugehört.

Delphi-Quellcode:
unit uWinGetAdaptersAddresses;

interface

uses Windows;

const
  MAX_ADAPTER_ADDRESS_LENGTH = 8;
  MAX_DHCPV6_DUID_LENGTH = 130;

//ifType Const
  IF_TYPE_OTHER = 1;
  IF_TYPE_ETHERNET_CSMACD = 6;
  IF_TYPE_ISO88025_TOKENRING = 9;
  IF_TYPE_PPP = 23;
  IF_TYPE_SOFTWARE_LOOPBACK = 24;
  IF_TYPE_ATM = 37;
  IF_TYPE_IEEE80211 = 71;
  IF_TYPE_TUNNEL = 131;
  IF_TYPE_IEEE1394 = 144;

//OperStatus Const
  IfOperStatusUp = 1;
  IfOperStatusDown = 2;
  IfOperStatusTesting = 3;
  IfOperStatusUnknown = 4;
  IfOperStatusDormant = 5;
  IfOperStatusNotPresent = 6;
  IfOperStatusLowerLayerDown = 7;

//ConnectionType Const
  NET_IF_CONNECTION_DEDICATED = 1;
  NET_IF_CONNECTION_PASSIVE = 2;
  NET_IF_CONNECTION_DEMAND = 3;
  NET_IF_CONNECTION_MAXIMUM = 4;
type


//http://msdn.microsoft.com/en-us/library/ms740496(VS.85).aspx

PSOCKADDR = ^SOCKADDR;
SOCKADDR = record
  sa_family : ShortInt;
  sa_data : array[0..13] of Char;
end;


//http://msdn.microsoft.com/en-us/library/ms740507(VS.85).aspx

PSOCKET_ADDRESS = ^SOCKET_ADDRESS;
SOCKET_ADDRESS = record
  lpSocketaddr : PSOCKADDR;
  iSockaddrLength : Integer;
end;

//http://msdn.microsoft.com/en-us/library/aa366281(VS.85).aspx

IP_PREFIX_ORIGIN = (
  IpPrefixOriginOther = 0,
  IpPrefixOriginManual,
  IpPrefixOriginWellKnown,
  IpPrefixOriginDhcp,
  IpPrefixOriginRouterAdvertisement,
  IpPrefixOriginUnchanged = 16
);


//http://msdn.microsoft.com/en-us/library/aa366283(VS.85).aspx

IP_SUFFIX_ORIGIN = (
  IpSuffixOriginOther = 0,
  IpSuffixOriginManual,
  IpSuffixOriginWellKnown,
  IpSuffixOriginDhcp,
  IpSuffixOriginLinkLayerAddress,
  IpSuffixOriginRandom,
  IpSuffixOriginUnchanged = 16
);


//http://msdn.microsoft.com/en-us/library/aa366069(VS.85).aspx

IP_DAD_STATE = (
  IpDadStateInvalid = 0,
  IpDadStateTentative,
  IpDadStateDuplicate,
  IpDadStateDeprecated,
  IpDadStatePreferred
);

//http://msdn.microsoft.com/en-us/library/aa366066(VS.85).aspx

PIP_ADAPTER_UNICAST_ADDRESS = ^IP_ADAPTER_UNICAST_ADDRESS;
IP_ADAPTER_UNICAST_ADDRESS = record
  union: record
    case Integer of
    0: (Length: LongInt; Flags: DWORD);
    end;
  Next : PIP_ADAPTER_UNICAST_ADDRESS;
  Address : SOCKET_ADDRESS;
  PrefixOrigin : IP_PREFIX_ORIGIN;
  SuffixOrigin : IP_SUFFIX_ORIGIN;
  DadState : IP_DAD_STATE;
  ValidLifeTime : LongInt;
  PreferredLifeTime : LongInt;
  LeaseLifeTime : LongInt;
  OnLinkPrefixLength : array[0..7] of Integer;
end;


//http://msdn.microsoft.com/en-us/library/aa366059(VS.85).aspx

PIP_ADAPTER_ANYCAST_ADDRESS = ^IP_ADAPTER_ANYCAST_ADDRESS;
IP_ADAPTER_ANYCAST_ADDRESS = record
  union: record
    case Integer of
      0: (Alignment: LongInt);
      1: (Length: LongInt; Flags: DWORD);
    end;
  Next : PIP_ADAPTER_ANYCAST_ADDRESS;
  Address : SOCKET_ADDRESS;
end;


//http://msdn.microsoft.com/en-us/library/aa366063(VS.85).aspx

PIP_ADAPTER_MULTICAST_ADDRESS = ^IP_ADAPTER_MULTICAST_ADDRESS;
IP_ADAPTER_MULTICAST_ADDRESS = record
  union: record
    case Integer of
      0: (Alignment: LongInt);
      1: (Length: LongInt; Flags: DWORD);
    end;
  Next : PIP_ADAPTER_MULTICAST_ADDRESS;
  Address : SOCKET_ADDRESS;
end;


//http://msdn.microsoft.com/en-us/library/aa366060(VS.85).aspx

PIP_ADAPTER_DNS_SERVER_ADDRESS = ^IP_ADAPTER_DNS_SERVER_ADDRESS;
IP_ADAPTER_DNS_SERVER_ADDRESS = record
  union: record
    case Integer of
      0: (Alignment: LongInt);
      1: (Length: LongInt; Reserved: DWORD);
    end;
    Next : PIP_ADAPTER_DNS_SERVER_ADDRESS;
    Address : SOCKET_ADDRESS;
end;


//http://msdn.microsoft.com/en-us/library/aa366065(VS.85).aspx

PIP_ADAPTER_PREFIX = ^IP_ADAPTER_PREFIX;
IP_ADAPTER_PREFIX = record
  union: record
    case Integer of
      0: (Alignment: LongInt);
      1: (Length: LongInt; Flags: DWORD);
    end;
  Next : PIP_ADAPTER_PREFIX;
  Address : SOCKET_ADDRESS;
  PrefixLength : LongInt;
end;


//http://msdn.microsoft.com/en-us/library/aa366058(VS.85).aspx

PIP_ADAPTER_ADDRESSES = ^IP_ADAPTER_ADDRESSES;
IP_ADAPTER_ADDRESSES = record
  union: record
    case Integer of
      0: (Alignment: LongInt);
      1: (Length: LongInt; IfIndex: DWORD);
    end;
  Next : PIP_ADAPTER_ADDRESSES;
  AdapterName : PCHAR;
  FirstUnicastAddress : PIP_ADAPTER_UNICAST_ADDRESS;
  FirstAnycastAddress : PIP_ADAPTER_ANYCAST_ADDRESS;
  FirstMulticastAddress : PIP_ADAPTER_MULTICAST_ADDRESS;
  FirstDnsServerAddress : PIP_ADAPTER_DNS_SERVER_ADDRESS;
  DnsSuffix : PWCHAR;
  Description : PWCHAR;
  FriendlyName : PWCHAR;
  PhysicalAdress : array[0..MAX_ADAPTER_ADDRESS_LENGTH - 1] of BYTE;
  PhysicalAdressLength : DWORD;
  Flags : DWORD;
  Mtu : DWORD;
  IfType : DWORD;
// OperStatus : IF_OPER_STATUS;
  Ipv6IfIndex : DWORD;
  ZoneIndices : array[0..15] of DWORD;
  FirstPrefix : PIP_ADAPTER_PREFIX;
  TransmitLinkSpeed : Int64;
  ReceiveLinkSpeed : Int64;
// FirstWinsServerAddress: PIP_ADAPTER_WINS_SERVER_ADDRESS_LH;
// FirstGatewayAddress : PIP_ADAPTER_GATEWAY_ADDRESS_LH;
  Ipv4Metric : LongInt;
  Ipv6Metric : LongInt;
// Luid : IF_LUID;
  Dhcpv4Server : SOCKET_ADDRESS;
// CompartmentId : NET_IF_COMPARTMENT_ID; [This member is not currently supported and is reserved for future use]
// NetworkGuid : NET_IF_NETWORK_GUID;
// ConnectionType : NET_IF_CONNECTION_TYPE;
// TunnelType : TUNNEL_TYPE;
  Dhcpv6Server : SOCKET_ADDRESS;
  Dhcpv6ClientDuid : array[0..MAX_DHCPV6_DUID_LENGTH - 1] of BYTE;
  Dhcpv6ClientDuidLength: LongInt;
  Dhcpv6Iaid : LongInt;
// FirstDnsSuffix : PIP_ADAPTER_DNS_SUFFIX;
end;


PVOID = Pointer;

//http://msdn.microsoft.com/en-us/library/aa365915(VS.85).aspx

function GetAdaptersAddresses(Family: ULONG; Flags: DWORD; Reserved: PVOID;
                             pAdapterAddresses: PIP_ADAPTER_ADDRESSES;
                             pOutBufLen: PULONG): DWORD; stdcall;
                             external 'IPHLPAPI.DLLname 'GetAdaptersAddresses';

implementation

end.
Alles was noch fehlt, bitte mir schreiben, damit ich es hinzufügen kann.
Da ich selber kein Windows Vista verwende, habe ich einige Dinge erstmal kommentiert. Können noch im nachhinein hinzugefügt werden

Danke für eure Hilfe.

Edit:
Fehler gelöst.
Edit2:
Rechtschreibfehler geändert.
Lars S.
Wer nicht mit der Zeit geht, geht mit der Zeit.
  Mit Zitat antworten Zitat