Win32 API 日本語リファレンス
ホームNetworkManagement.IpHelper › IP_ADAPTER_ADDRESSES_XP

IP_ADAPTER_ADDRESSES_XP

構造体
サイズx64: 184 バイト / x86: 144 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
Anonymous_Anonymous_e__Union8+0+0LengthとIfIndexを保持する匿名共用体である。
NextIP_ADAPTER_ADDRESSES_XP*8/4+8+8連結リスト上の次のアダプタ要素を指すポインタである。末尾はNULL。
AdapterNameLPSTR8/4+16+12アダプタを一意に識別するANSI文字列(GUID形式)へのポインタである。
FirstUnicastAddressIP_ADAPTER_UNICAST_ADDRESS_XP*8/4+24+16ユニキャストアドレス連結リストの先頭要素へのポインタである。
FirstAnycastAddressIP_ADAPTER_ANYCAST_ADDRESS_XP*8/4+32+20エニーキャストアドレス連結リストの先頭要素へのポインタである。
FirstMulticastAddressIP_ADAPTER_MULTICAST_ADDRESS_XP*8/4+40+24マルチキャストアドレス連結リストの先頭要素へのポインタである。
FirstDnsServerAddressIP_ADAPTER_DNS_SERVER_ADDRESS_XP*8/4+48+28DNSサーバーアドレス連結リストの先頭要素へのポインタである。
DnsSuffixLPWSTR8/4+56+32アダプタ固有のDNSサフィックスを指すワイド文字列ポインタである。
DescriptionLPWSTR8/4+64+36アダプタの説明文を指すワイド文字列ポインタである。
FriendlyNameLPWSTR8/4+72+40ユーザー向けのアダプタ表示名を指すワイド文字列ポインタである。
PhysicalAddressBYTE8+80+44アダプタの物理(MAC)アドレスを保持するバイト配列である。
PhysicalAddressLengthDWORD4+88+52PhysicalAddressの有効長(バイト数)である。
FlagsDWORD4+92+56DDNS有効等のアダプタ属性を示すビットフラグである。
MtuDWORD4+96+60インタフェースの最大伝送単位(MTU)をバイト単位で示す。
IfTypeDWORD4+100+64インタフェースの種別(IANA ifType値)を示す。
OperStatusIF_OPER_STATUS4+104+68インタフェースの運用状態(IF_OPER_STATUS)を示す。
Ipv6IfIndexDWORD4+108+72このアダプタのIPv6インタフェースインデックスである。
ZoneIndicesDWORD64+112+76各IPv6スコープレベルに対応するゾーンインデックスの配列である。
FirstPrefixIP_ADAPTER_PREFIX_XP*8/4+176+140アダプタに関連付けられたプレフィックス連結リストの先頭要素である。

共用体: _Anonymous_e__Union x64 8B / x86 8B

フィールドサイズx64x86説明
AlignmentULONGLONG8+0+0
Anonymous_Anonymous_e__Struct8/4+0+0LengthとIfIndexを保持する匿名共用体である。

各言語での定義

#include <windows.h>

// IP_ADAPTER_ADDRESSES_XP  (x64 184 / x86 144 バイト)
typedef struct IP_ADAPTER_ADDRESSES_XP {
    _Anonymous_e__Union Anonymous;
    IP_ADAPTER_ADDRESSES_XP* Next;
    LPSTR AdapterName;
    IP_ADAPTER_UNICAST_ADDRESS_XP* FirstUnicastAddress;
    IP_ADAPTER_ANYCAST_ADDRESS_XP* FirstAnycastAddress;
    IP_ADAPTER_MULTICAST_ADDRESS_XP* FirstMulticastAddress;
    IP_ADAPTER_DNS_SERVER_ADDRESS_XP* FirstDnsServerAddress;
    LPWSTR DnsSuffix;
    LPWSTR Description;
    LPWSTR FriendlyName;
    BYTE PhysicalAddress[8];
    DWORD PhysicalAddressLength;
    DWORD Flags;
    DWORD Mtu;
    DWORD IfType;
    IF_OPER_STATUS OperStatus;
    DWORD Ipv6IfIndex;
    DWORD ZoneIndices[16];
    IP_ADAPTER_PREFIX_XP* FirstPrefix;
} IP_ADAPTER_ADDRESSES_XP;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct IP_ADAPTER_ADDRESSES_XP
{
    public _Anonymous_e__Union Anonymous;
    public IntPtr Next;
    public IntPtr AdapterName;
    public IntPtr FirstUnicastAddress;
    public IntPtr FirstAnycastAddress;
    public IntPtr FirstMulticastAddress;
    public IntPtr FirstDnsServerAddress;
    public IntPtr DnsSuffix;
    public IntPtr Description;
    public IntPtr FriendlyName;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public byte[] PhysicalAddress;
    public uint PhysicalAddressLength;
    public uint Flags;
    public uint Mtu;
    public uint IfType;
    public int OperStatus;
    public uint Ipv6IfIndex;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public uint[] ZoneIndices;
    public IntPtr FirstPrefix;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure IP_ADAPTER_ADDRESSES_XP
    Public Anonymous As _Anonymous_e__Union
    Public Next As IntPtr
    Public AdapterName As IntPtr
    Public FirstUnicastAddress As IntPtr
    Public FirstAnycastAddress As IntPtr
    Public FirstMulticastAddress As IntPtr
    Public FirstDnsServerAddress As IntPtr
    Public DnsSuffix As IntPtr
    Public Description As IntPtr
    Public FriendlyName As IntPtr
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=8)> Public PhysicalAddress() As Byte
    Public PhysicalAddressLength As UInteger
    Public Flags As UInteger
    Public Mtu As UInteger
    Public IfType As UInteger
    Public OperStatus As Integer
    Public Ipv6IfIndex As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=16)> Public ZoneIndices() As UInteger
    Public FirstPrefix As IntPtr
End Structure
import ctypes
from ctypes import wintypes

class IP_ADAPTER_ADDRESSES_XP(ctypes.Structure):
    _fields_ = [
        ("Anonymous", _Anonymous_e__Union),
        ("Next", ctypes.c_void_p),
        ("AdapterName", ctypes.c_void_p),
        ("FirstUnicastAddress", ctypes.c_void_p),
        ("FirstAnycastAddress", ctypes.c_void_p),
        ("FirstMulticastAddress", ctypes.c_void_p),
        ("FirstDnsServerAddress", ctypes.c_void_p),
        ("DnsSuffix", ctypes.c_void_p),
        ("Description", ctypes.c_void_p),
        ("FriendlyName", ctypes.c_void_p),
        ("PhysicalAddress", ctypes.c_ubyte * 8),
        ("PhysicalAddressLength", wintypes.DWORD),
        ("Flags", wintypes.DWORD),
        ("Mtu", wintypes.DWORD),
        ("IfType", wintypes.DWORD),
        ("OperStatus", ctypes.c_int),
        ("Ipv6IfIndex", wintypes.DWORD),
        ("ZoneIndices", wintypes.DWORD * 16),
        ("FirstPrefix", ctypes.c_void_p),
    ]
#[repr(C)]
pub struct IP_ADAPTER_ADDRESSES_XP {
    pub Anonymous: _Anonymous_e__Union,
    pub Next: *mut core::ffi::c_void,
    pub AdapterName: *mut core::ffi::c_void,
    pub FirstUnicastAddress: *mut core::ffi::c_void,
    pub FirstAnycastAddress: *mut core::ffi::c_void,
    pub FirstMulticastAddress: *mut core::ffi::c_void,
    pub FirstDnsServerAddress: *mut core::ffi::c_void,
    pub DnsSuffix: *mut core::ffi::c_void,
    pub Description: *mut core::ffi::c_void,
    pub FriendlyName: *mut core::ffi::c_void,
    pub PhysicalAddress: [u8; 8],
    pub PhysicalAddressLength: u32,
    pub Flags: u32,
    pub Mtu: u32,
    pub IfType: u32,
    pub OperStatus: i32,
    pub Ipv6IfIndex: u32,
    pub ZoneIndices: [u32; 16],
    pub FirstPrefix: *mut core::ffi::c_void,
}
import "golang.org/x/sys/windows"

type IP_ADAPTER_ADDRESSES_XP struct {
	Anonymous _Anonymous_e__Union
	Next uintptr
	AdapterName uintptr
	FirstUnicastAddress uintptr
	FirstAnycastAddress uintptr
	FirstMulticastAddress uintptr
	FirstDnsServerAddress uintptr
	DnsSuffix uintptr
	Description uintptr
	FriendlyName uintptr
	PhysicalAddress [8]byte
	PhysicalAddressLength uint32
	Flags uint32
	Mtu uint32
	IfType uint32
	OperStatus int32
	Ipv6IfIndex uint32
	ZoneIndices [16]uint32
	FirstPrefix uintptr
}
type
  IP_ADAPTER_ADDRESSES_XP = record
    Anonymous: _Anonymous_e__Union;
    Next: Pointer;
    AdapterName: Pointer;
    FirstUnicastAddress: Pointer;
    FirstAnycastAddress: Pointer;
    FirstMulticastAddress: Pointer;
    FirstDnsServerAddress: Pointer;
    DnsSuffix: Pointer;
    Description: Pointer;
    FriendlyName: Pointer;
    PhysicalAddress: array[0..7] of Byte;
    PhysicalAddressLength: DWORD;
    Flags: DWORD;
    Mtu: DWORD;
    IfType: DWORD;
    OperStatus: Integer;
    Ipv6IfIndex: DWORD;
    ZoneIndices: array[0..15] of DWORD;
    FirstPrefix: Pointer;
  end;
const IP_ADAPTER_ADDRESSES_XP = extern struct {
    Anonymous: _Anonymous_e__Union,
    Next: ?*anyopaque,
    AdapterName: ?*anyopaque,
    FirstUnicastAddress: ?*anyopaque,
    FirstAnycastAddress: ?*anyopaque,
    FirstMulticastAddress: ?*anyopaque,
    FirstDnsServerAddress: ?*anyopaque,
    DnsSuffix: ?*anyopaque,
    Description: ?*anyopaque,
    FriendlyName: ?*anyopaque,
    PhysicalAddress: [8]u8,
    PhysicalAddressLength: u32,
    Flags: u32,
    Mtu: u32,
    IfType: u32,
    OperStatus: i32,
    Ipv6IfIndex: u32,
    ZoneIndices: [16]u32,
    FirstPrefix: ?*anyopaque,
};
type
  IP_ADAPTER_ADDRESSES_XP {.bycopy.} = object
    Anonymous: _Anonymous_e__Union
    Next: pointer
    AdapterName: pointer
    FirstUnicastAddress: pointer
    FirstAnycastAddress: pointer
    FirstMulticastAddress: pointer
    FirstDnsServerAddress: pointer
    DnsSuffix: pointer
    Description: pointer
    FriendlyName: pointer
    PhysicalAddress: array[8, uint8]
    PhysicalAddressLength: uint32
    Flags: uint32
    Mtu: uint32
    IfType: uint32
    OperStatus: int32
    Ipv6IfIndex: uint32
    ZoneIndices: array[16, uint32]
    FirstPrefix: pointer
struct IP_ADAPTER_ADDRESSES_XP
{
    _Anonymous_e__Union Anonymous;
    void* Next;
    void* AdapterName;
    void* FirstUnicastAddress;
    void* FirstAnycastAddress;
    void* FirstMulticastAddress;
    void* FirstDnsServerAddress;
    void* DnsSuffix;
    void* Description;
    void* FriendlyName;
    ubyte[8] PhysicalAddress;
    uint PhysicalAddressLength;
    uint Flags;
    uint Mtu;
    uint IfType;
    int OperStatus;
    uint Ipv6IfIndex;
    uint[16] ZoneIndices;
    void* FirstPrefix;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; IP_ADAPTER_ADDRESSES_XP サイズ: 144 バイト(x86)
dim st, 36    ; 4byte整数×36(構造体サイズ 144 / 4 切り上げ)
; Anonymous : _Anonymous_e__Union (+0, 8byte)  varptr(st)+0 を基点に操作(8byte:入れ子/配列)
; Next : IP_ADAPTER_ADDRESSES_XP* (+8, 4byte)  varptr(st)+8 を基点に操作(4byte:入れ子/配列)
; AdapterName : LPSTR (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; FirstUnicastAddress : IP_ADAPTER_UNICAST_ADDRESS_XP* (+16, 4byte)  varptr(st)+16 を基点に操作(4byte:入れ子/配列)
; FirstAnycastAddress : IP_ADAPTER_ANYCAST_ADDRESS_XP* (+20, 4byte)  varptr(st)+20 を基点に操作(4byte:入れ子/配列)
; FirstMulticastAddress : IP_ADAPTER_MULTICAST_ADDRESS_XP* (+24, 4byte)  varptr(st)+24 を基点に操作(4byte:入れ子/配列)
; FirstDnsServerAddress : IP_ADAPTER_DNS_SERVER_ADDRESS_XP* (+28, 4byte)  varptr(st)+28 を基点に操作(4byte:入れ子/配列)
; DnsSuffix : LPWSTR (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; Description : LPWSTR (+36, 4byte)  st.9 = 値  /  値 = st.9   (lpoke/lpeek も可)
; FriendlyName : LPWSTR (+40, 4byte)  st.10 = 値  /  値 = st.10   (lpoke/lpeek も可)
; PhysicalAddress : BYTE (+44, 8byte)  varptr(st)+44 を基点に操作(8byte:入れ子/配列)
; PhysicalAddressLength : DWORD (+52, 4byte)  st.13 = 値  /  値 = st.13   (lpoke/lpeek も可)
; Flags : DWORD (+56, 4byte)  st.14 = 値  /  値 = st.14   (lpoke/lpeek も可)
; Mtu : DWORD (+60, 4byte)  st.15 = 値  /  値 = st.15   (lpoke/lpeek も可)
; IfType : DWORD (+64, 4byte)  st.16 = 値  /  値 = st.16   (lpoke/lpeek も可)
; OperStatus : IF_OPER_STATUS (+68, 4byte)  st.17 = 値  /  値 = st.17   (lpoke/lpeek も可)
; Ipv6IfIndex : DWORD (+72, 4byte)  st.18 = 値  /  値 = st.18   (lpoke/lpeek も可)
; ZoneIndices : DWORD (+76, 64byte)  varptr(st)+76 を基点に操作(64byte:入れ子/配列)
; FirstPrefix : IP_ADAPTER_PREFIX_XP* (+140, 4byte)  varptr(st)+140 を基点に操作(4byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; IP_ADAPTER_ADDRESSES_XP サイズ: 184 バイト(x64)
dim st, 46    ; 4byte整数×46(構造体サイズ 184 / 4 切り上げ)
; Anonymous : _Anonymous_e__Union (+0, 8byte)  varptr(st)+0 を基点に操作(8byte:入れ子/配列)
; Next : IP_ADAPTER_ADDRESSES_XP* (+8, 8byte)  varptr(st)+8 を基点に操作(8byte:入れ子/配列)
; AdapterName : LPSTR (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; FirstUnicastAddress : IP_ADAPTER_UNICAST_ADDRESS_XP* (+24, 8byte)  varptr(st)+24 を基点に操作(8byte:入れ子/配列)
; FirstAnycastAddress : IP_ADAPTER_ANYCAST_ADDRESS_XP* (+32, 8byte)  varptr(st)+32 を基点に操作(8byte:入れ子/配列)
; FirstMulticastAddress : IP_ADAPTER_MULTICAST_ADDRESS_XP* (+40, 8byte)  varptr(st)+40 を基点に操作(8byte:入れ子/配列)
; FirstDnsServerAddress : IP_ADAPTER_DNS_SERVER_ADDRESS_XP* (+48, 8byte)  varptr(st)+48 を基点に操作(8byte:入れ子/配列)
; DnsSuffix : LPWSTR (+56, 8byte)  qpoke st,56,値 / qpeek(st,56)  ※IronHSPのみ。3.7/3.8は lpoke st,56,下位 : lpoke st,60,上位
; Description : LPWSTR (+64, 8byte)  qpoke st,64,値 / qpeek(st,64)  ※IronHSPのみ。3.7/3.8は lpoke st,64,下位 : lpoke st,68,上位
; FriendlyName : LPWSTR (+72, 8byte)  qpoke st,72,値 / qpeek(st,72)  ※IronHSPのみ。3.7/3.8は lpoke st,72,下位 : lpoke st,76,上位
; PhysicalAddress : BYTE (+80, 8byte)  varptr(st)+80 を基点に操作(8byte:入れ子/配列)
; PhysicalAddressLength : DWORD (+88, 4byte)  st.22 = 値  /  値 = st.22   (lpoke/lpeek も可)
; Flags : DWORD (+92, 4byte)  st.23 = 値  /  値 = st.23   (lpoke/lpeek も可)
; Mtu : DWORD (+96, 4byte)  st.24 = 値  /  値 = st.24   (lpoke/lpeek も可)
; IfType : DWORD (+100, 4byte)  st.25 = 値  /  値 = st.25   (lpoke/lpeek も可)
; OperStatus : IF_OPER_STATUS (+104, 4byte)  st.26 = 値  /  値 = st.26   (lpoke/lpeek も可)
; Ipv6IfIndex : DWORD (+108, 4byte)  st.27 = 値  /  値 = st.27   (lpoke/lpeek も可)
; ZoneIndices : DWORD (+112, 64byte)  varptr(st)+112 を基点に操作(64byte:入れ子/配列)
; FirstPrefix : IP_ADAPTER_PREFIX_XP* (+176, 8byte)  varptr(st)+176 を基点に操作(8byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global IP_ADAPTER_ADDRESSES_XP
    #field byte Anonymous 8
    #field intptr Next
    #field intptr AdapterName
    #field intptr FirstUnicastAddress
    #field intptr FirstAnycastAddress
    #field intptr FirstMulticastAddress
    #field intptr FirstDnsServerAddress
    #field intptr DnsSuffix
    #field intptr Description
    #field intptr FriendlyName
    #field byte PhysicalAddress 8
    #field int PhysicalAddressLength
    #field int Flags
    #field int Mtu
    #field int IfType
    #field int OperStatus
    #field int Ipv6IfIndex
    #field int ZoneIndices 16
    #field intptr FirstPrefix
#endstruct

stdim st, IP_ADAPTER_ADDRESSES_XP        ; NSTRUCT 変数を確保
st->PhysicalAddressLength = 100
mes "PhysicalAddressLength=" + st->PhysicalAddressLength
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。