Einzelnen Beitrag anzeigen

jackie
(Gast)

n/a Beiträge
 
#4

Re: C- union Struktur in Delphi

  Alt 1. Mai 2005, 16:06
Hallo!
Also erstmal danke für die Antworten.
Die originale Struktur (C) sieht so aus:
Code:
typedef struct _IP_ADAPTER_ADDRESSES {
  union {
    ULONGLONG Alignment;
    struct {
      ULONG Length;
      DWORD IfIndex;
    };
  };
  struct _IP_ADAPTER_ADDRESSES* Next;
  PCHAR AdapterName;
  PIP_ADAPTER_UNICAST_ADDRESS FirstUnicastAddress;
  PIP_ADAPTER_ANYCAST_ADDRESS FirstAnycastAddress;
  PIP_ADAPTER_MULTICAST_ADDRESS FirstMulticastAddress;
  PIP_ADAPTER_DNS_SERVER_ADDRESS FirstDnsServerAddress;
  PWCHAR DnsSuffix;
  PWCHAR Description;
  PWCHAR FriendlyName;
  BYTE PhysicalAddress[MAX_ADAPTER_ADDRESS_LENGTH];
  DWORD PhysicalAddressLength;
  DWORD Flags;
  DWORD Mtu;
  DWORD IfType;
  IF_OPER_STATUS OperStatus;
  DWORD Ipv6IfIndex;
  DWORD ZoneIndices[16];
  PIP_ADAPTER_PREFIX FirstPrefix;
} IP_ADAPTER_ADDRESSES,
*PIP_ADAPTER_ADDRESSES;
Ich habs jetzt so übersetzt:
Delphi-Quellcode:
PIP_ADAPTER_ADDRESSES = ^TIP_ADAPTER_ADDRESSES;
  TIP_ADAPTER_ADDRESSES = packed record
      {struct _IP_ADAPTER_ADDRESSES* Next;}
      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;
      PhysicalAddress: Byte[MAX_ADAPTER_ADDRESS_LENGTH];
      PhysicalAddressLength: DWord;
      Flags: DWord;
      Mtu: DWord;
      IfType: DWord;
      OperStatus: IF_OPER_STATUS;
      Ipv6Index: DWord;
      ZoneIndices: DWORD[16];
      FirstPrefix: PIP_ADAPTER_PREFIX;
      {union??}
    end;
Bei den Sachen in Klammern bin ich mir nicht sicher. Ich weis auch nicht, welchen Namen ich dem union geben soll?!
Zitat:
Der variante Teil muss am Ende der Record-Deklaration stehen, so dass man ziemliche Verrenkungen machen muss, wenn man so eine Struktur mittendrin braucht.
Das sollte hier aber eigentlich kein Problem sein, oder?
  Mit Zitat antworten Zitat