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

IP_PER_ADAPTER_INFO_W2KSP1

構造体
サイズx64: 64 バイト / x86: 52 バイト

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

フィールド

フィールドサイズx64x86説明
AutoconfigEnabledDWORD4+0+0自動構成(APIPA)が有効かどうかを示す(0/非0)。
AutoconfigActiveDWORD4+4+4自動構成が現在動作中かどうかを示す(0/非0)。
CurrentDnsServerIP_ADDR_STRING*8/4+8+8現在使用中のDNSサーバーを指すポインタで予約済みである。
DnsServerListIP_ADDR_STRING48/40+16+12このアダプタに構成されたDNSサーバーのIPアドレス連結リストである。

各言語での定義

#include <windows.h>

// IP_ADDRESS_STRING  (x64 16 / x86 16 バイト)
typedef struct IP_ADDRESS_STRING {
    CHAR String[16];
} IP_ADDRESS_STRING;

// IP_ADDR_STRING  (x64 48 / x86 40 バイト)
typedef struct IP_ADDR_STRING {
    IP_ADDR_STRING* Next;
    IP_ADDRESS_STRING IpAddress;
    IP_ADDRESS_STRING IpMask;
    DWORD Context;
} IP_ADDR_STRING;

// IP_PER_ADAPTER_INFO_W2KSP1  (x64 64 / x86 52 バイト)
typedef struct IP_PER_ADAPTER_INFO_W2KSP1 {
    DWORD AutoconfigEnabled;
    DWORD AutoconfigActive;
    IP_ADDR_STRING* CurrentDnsServer;
    IP_ADDR_STRING DnsServerList;
} IP_PER_ADAPTER_INFO_W2KSP1;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct IP_ADDRESS_STRING
{
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public sbyte[] String;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct IP_ADDR_STRING
{
    public IntPtr Next;
    public IP_ADDRESS_STRING IpAddress;
    public IP_ADDRESS_STRING IpMask;
    public uint Context;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct IP_PER_ADAPTER_INFO_W2KSP1
{
    public uint AutoconfigEnabled;
    public uint AutoconfigActive;
    public IntPtr CurrentDnsServer;
    public IP_ADDR_STRING DnsServerList;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure IP_ADDRESS_STRING
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=16)> Public String() As SByte
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure IP_ADDR_STRING
    Public Next As IntPtr
    Public IpAddress As IP_ADDRESS_STRING
    Public IpMask As IP_ADDRESS_STRING
    Public Context As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure IP_PER_ADAPTER_INFO_W2KSP1
    Public AutoconfigEnabled As UInteger
    Public AutoconfigActive As UInteger
    Public CurrentDnsServer As IntPtr
    Public DnsServerList As IP_ADDR_STRING
End Structure
import ctypes
from ctypes import wintypes

class IP_ADDRESS_STRING(ctypes.Structure):
    _fields_ = [
        ("String", ctypes.c_byte * 16),
    ]

class IP_ADDR_STRING(ctypes.Structure):
    _fields_ = [
        ("Next", ctypes.c_void_p),
        ("IpAddress", IP_ADDRESS_STRING),
        ("IpMask", IP_ADDRESS_STRING),
        ("Context", wintypes.DWORD),
    ]

class IP_PER_ADAPTER_INFO_W2KSP1(ctypes.Structure):
    _fields_ = [
        ("AutoconfigEnabled", wintypes.DWORD),
        ("AutoconfigActive", wintypes.DWORD),
        ("CurrentDnsServer", ctypes.c_void_p),
        ("DnsServerList", IP_ADDR_STRING),
    ]
#[repr(C)]
pub struct IP_ADDRESS_STRING {
    pub String: [i8; 16],
}

#[repr(C)]
pub struct IP_ADDR_STRING {
    pub Next: *mut core::ffi::c_void,
    pub IpAddress: IP_ADDRESS_STRING,
    pub IpMask: IP_ADDRESS_STRING,
    pub Context: u32,
}

#[repr(C)]
pub struct IP_PER_ADAPTER_INFO_W2KSP1 {
    pub AutoconfigEnabled: u32,
    pub AutoconfigActive: u32,
    pub CurrentDnsServer: *mut core::ffi::c_void,
    pub DnsServerList: IP_ADDR_STRING,
}
import "golang.org/x/sys/windows"

type IP_ADDRESS_STRING struct {
	String [16]int8
}

type IP_ADDR_STRING struct {
	Next uintptr
	IpAddress IP_ADDRESS_STRING
	IpMask IP_ADDRESS_STRING
	Context uint32
}

type IP_PER_ADAPTER_INFO_W2KSP1 struct {
	AutoconfigEnabled uint32
	AutoconfigActive uint32
	CurrentDnsServer uintptr
	DnsServerList IP_ADDR_STRING
}
type
  IP_ADDRESS_STRING = record
    String: array[0..15] of Shortint;
  end;

  IP_ADDR_STRING = record
    Next: Pointer;
    IpAddress: IP_ADDRESS_STRING;
    IpMask: IP_ADDRESS_STRING;
    Context: DWORD;
  end;

  IP_PER_ADAPTER_INFO_W2KSP1 = record
    AutoconfigEnabled: DWORD;
    AutoconfigActive: DWORD;
    CurrentDnsServer: Pointer;
    DnsServerList: IP_ADDR_STRING;
  end;
const IP_ADDRESS_STRING = extern struct {
    String: [16]i8,
};

const IP_ADDR_STRING = extern struct {
    Next: ?*anyopaque,
    IpAddress: IP_ADDRESS_STRING,
    IpMask: IP_ADDRESS_STRING,
    Context: u32,
};

const IP_PER_ADAPTER_INFO_W2KSP1 = extern struct {
    AutoconfigEnabled: u32,
    AutoconfigActive: u32,
    CurrentDnsServer: ?*anyopaque,
    DnsServerList: IP_ADDR_STRING,
};
type
  IP_ADDRESS_STRING {.bycopy.} = object
    String: array[16, int8]

  IP_ADDR_STRING {.bycopy.} = object
    Next: pointer
    IpAddress: IP_ADDRESS_STRING
    IpMask: IP_ADDRESS_STRING
    Context: uint32

  IP_PER_ADAPTER_INFO_W2KSP1 {.bycopy.} = object
    AutoconfigEnabled: uint32
    AutoconfigActive: uint32
    CurrentDnsServer: pointer
    DnsServerList: IP_ADDR_STRING
struct IP_ADDRESS_STRING
{
    byte[16] String;
}

struct IP_ADDR_STRING
{
    void* Next;
    IP_ADDRESS_STRING IpAddress;
    IP_ADDRESS_STRING IpMask;
    uint Context;
}

struct IP_PER_ADAPTER_INFO_W2KSP1
{
    uint AutoconfigEnabled;
    uint AutoconfigActive;
    void* CurrentDnsServer;
    IP_ADDR_STRING DnsServerList;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; IP_PER_ADAPTER_INFO_W2KSP1 サイズ: 52 バイト(x86)
dim st, 13    ; 4byte整数×13(構造体サイズ 52 / 4 切り上げ)
; AutoconfigEnabled : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; AutoconfigActive : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; CurrentDnsServer : IP_ADDR_STRING* (+8, 4byte)  varptr(st)+8 を基点に操作(4byte:入れ子/配列)
; DnsServerList : IP_ADDR_STRING (+12, 40byte)  varptr(st)+12 を基点に操作(40byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; IP_PER_ADAPTER_INFO_W2KSP1 サイズ: 64 バイト(x64)
dim st, 16    ; 4byte整数×16(構造体サイズ 64 / 4 切り上げ)
; AutoconfigEnabled : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; AutoconfigActive : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; CurrentDnsServer : IP_ADDR_STRING* (+8, 8byte)  varptr(st)+8 を基点に操作(8byte:入れ子/配列)
; DnsServerList : IP_ADDR_STRING (+16, 48byte)  varptr(st)+16 を基点に操作(48byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global IP_ADDRESS_STRING
    #field byte String 16
#endstruct

#defstruct global IP_ADDR_STRING
    #field intptr Next
    #field IP_ADDRESS_STRING IpAddress
    #field IP_ADDRESS_STRING IpMask
    #field int Context
#endstruct

#defstruct global IP_PER_ADAPTER_INFO_W2KSP1
    #field int AutoconfigEnabled
    #field int AutoconfigActive
    #field intptr CurrentDnsServer
    #field IP_ADDR_STRING DnsServerList
#endstruct

stdim st, IP_PER_ADAPTER_INFO_W2KSP1        ; NSTRUCT 変数を確保
st->AutoconfigEnabled = 100
mes "AutoconfigEnabled=" + st->AutoconfigEnabled