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

MIB_IPNETTABLE

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

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

フィールド

フィールドサイズx64x86説明
dwNumEntriesDWORD4+0+0table配列に格納されたARP行数を示す。
tableMIB_IPNETROW_LH24+4+4MIB_IPNETROW_LH要素を格納する可変長配列の先頭。

各言語での定義

#include <windows.h>

// MIB_IPNETROW_LH  (x64 24 / x86 24 バイト)
typedef struct MIB_IPNETROW_LH {
    DWORD dwIndex;
    DWORD dwPhysAddrLen;
    BYTE bPhysAddr[8];
    DWORD dwAddr;
    _Anonymous_e__Union Anonymous;
} MIB_IPNETROW_LH;

// MIB_IPNETTABLE  (x64 28 / x86 28 バイト)
typedef struct MIB_IPNETTABLE {
    DWORD dwNumEntries;
    MIB_IPNETROW_LH table[1];
} MIB_IPNETTABLE;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct MIB_IPNETROW_LH
{
    public uint dwIndex;
    public uint dwPhysAddrLen;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public byte[] bPhysAddr;
    public uint dwAddr;
    public _Anonymous_e__Union Anonymous;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct MIB_IPNETTABLE
{
    public uint dwNumEntries;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public MIB_IPNETROW_LH[] table;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure MIB_IPNETROW_LH
    Public dwIndex As UInteger
    Public dwPhysAddrLen As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=8)> Public bPhysAddr() As Byte
    Public dwAddr As UInteger
    Public Anonymous As _Anonymous_e__Union
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure MIB_IPNETTABLE
    Public dwNumEntries As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public table() As MIB_IPNETROW_LH
End Structure
import ctypes
from ctypes import wintypes

class MIB_IPNETROW_LH(ctypes.Structure):
    _fields_ = [
        ("dwIndex", wintypes.DWORD),
        ("dwPhysAddrLen", wintypes.DWORD),
        ("bPhysAddr", ctypes.c_ubyte * 8),
        ("dwAddr", wintypes.DWORD),
        ("Anonymous", _Anonymous_e__Union),
    ]

class MIB_IPNETTABLE(ctypes.Structure):
    _fields_ = [
        ("dwNumEntries", wintypes.DWORD),
        ("table", MIB_IPNETROW_LH * 1),
    ]
#[repr(C)]
pub struct MIB_IPNETROW_LH {
    pub dwIndex: u32,
    pub dwPhysAddrLen: u32,
    pub bPhysAddr: [u8; 8],
    pub dwAddr: u32,
    pub Anonymous: _Anonymous_e__Union,
}

#[repr(C)]
pub struct MIB_IPNETTABLE {
    pub dwNumEntries: u32,
    pub table: [MIB_IPNETROW_LH; 1],
}
import "golang.org/x/sys/windows"

type MIB_IPNETROW_LH struct {
	dwIndex uint32
	dwPhysAddrLen uint32
	bPhysAddr [8]byte
	dwAddr uint32
	Anonymous _Anonymous_e__Union
}

type MIB_IPNETTABLE struct {
	dwNumEntries uint32
	table [1]MIB_IPNETROW_LH
}
type
  MIB_IPNETROW_LH = record
    dwIndex: DWORD;
    dwPhysAddrLen: DWORD;
    bPhysAddr: array[0..7] of Byte;
    dwAddr: DWORD;
    Anonymous: _Anonymous_e__Union;
  end;

  MIB_IPNETTABLE = record
    dwNumEntries: DWORD;
    table: array[0..0] of MIB_IPNETROW_LH;
  end;
const MIB_IPNETROW_LH = extern struct {
    dwIndex: u32,
    dwPhysAddrLen: u32,
    bPhysAddr: [8]u8,
    dwAddr: u32,
    Anonymous: _Anonymous_e__Union,
};

const MIB_IPNETTABLE = extern struct {
    dwNumEntries: u32,
    table: [1]MIB_IPNETROW_LH,
};
type
  MIB_IPNETROW_LH {.bycopy.} = object
    dwIndex: uint32
    dwPhysAddrLen: uint32
    bPhysAddr: array[8, uint8]
    dwAddr: uint32
    Anonymous: _Anonymous_e__Union

  MIB_IPNETTABLE {.bycopy.} = object
    dwNumEntries: uint32
    table: array[1, MIB_IPNETROW_LH]
struct MIB_IPNETROW_LH
{
    uint dwIndex;
    uint dwPhysAddrLen;
    ubyte[8] bPhysAddr;
    uint dwAddr;
    _Anonymous_e__Union Anonymous;
}

struct MIB_IPNETTABLE
{
    uint dwNumEntries;
    MIB_IPNETROW_LH[1] table;
}

HSP用 定義

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

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

#defstruct global MIB_IPNETTABLE
    #field int dwNumEntries
    #field MIB_IPNETROW_LH table 1
#endstruct

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