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

MIB_IPNETROW_W2K

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

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

フィールド

フィールドサイズx64x86説明
dwIndexDWORD4+0+0このARPエントリを持つインターフェースのインデックスを示す。
dwPhysAddrLenDWORD4+4+4bPhysAddrに格納された物理アドレスのバイト長を示す。
bPhysAddrBYTE8+8+8IPアドレスに対応する物理(MAC)アドレスを格納する固定長配列。
dwAddrDWORD4+16+16物理アドレスに対応するIPv4アドレスを保持する。
dwTypeDWORD4+20+20ARPエントリの種別(静的/動的/無効等)を示す。

各言語での定義

#include <windows.h>

// MIB_IPNETROW_W2K  (x64 24 / x86 24 バイト)
typedef struct MIB_IPNETROW_W2K {
    DWORD dwIndex;
    DWORD dwPhysAddrLen;
    BYTE bPhysAddr[8];
    DWORD dwAddr;
    DWORD dwType;
} MIB_IPNETROW_W2K;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct MIB_IPNETROW_W2K
{
    public uint dwIndex;
    public uint dwPhysAddrLen;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public byte[] bPhysAddr;
    public uint dwAddr;
    public uint dwType;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure MIB_IPNETROW_W2K
    Public dwIndex As UInteger
    Public dwPhysAddrLen As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=8)> Public bPhysAddr() As Byte
    Public dwAddr As UInteger
    Public dwType As UInteger
End Structure
import ctypes
from ctypes import wintypes

class MIB_IPNETROW_W2K(ctypes.Structure):
    _fields_ = [
        ("dwIndex", wintypes.DWORD),
        ("dwPhysAddrLen", wintypes.DWORD),
        ("bPhysAddr", ctypes.c_ubyte * 8),
        ("dwAddr", wintypes.DWORD),
        ("dwType", wintypes.DWORD),
    ]
#[repr(C)]
pub struct MIB_IPNETROW_W2K {
    pub dwIndex: u32,
    pub dwPhysAddrLen: u32,
    pub bPhysAddr: [u8; 8],
    pub dwAddr: u32,
    pub dwType: u32,
}
import "golang.org/x/sys/windows"

type MIB_IPNETROW_W2K struct {
	dwIndex uint32
	dwPhysAddrLen uint32
	bPhysAddr [8]byte
	dwAddr uint32
	dwType uint32
}
type
  MIB_IPNETROW_W2K = record
    dwIndex: DWORD;
    dwPhysAddrLen: DWORD;
    bPhysAddr: array[0..7] of Byte;
    dwAddr: DWORD;
    dwType: DWORD;
  end;
const MIB_IPNETROW_W2K = extern struct {
    dwIndex: u32,
    dwPhysAddrLen: u32,
    bPhysAddr: [8]u8,
    dwAddr: u32,
    dwType: u32,
};
type
  MIB_IPNETROW_W2K {.bycopy.} = object
    dwIndex: uint32
    dwPhysAddrLen: uint32
    bPhysAddr: array[8, uint8]
    dwAddr: uint32
    dwType: uint32
struct MIB_IPNETROW_W2K
{
    uint dwIndex;
    uint dwPhysAddrLen;
    ubyte[8] bPhysAddr;
    uint dwAddr;
    uint dwType;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; MIB_IPNETROW_W2K サイズ: 24 バイト(x64)
dim st, 6    ; 4byte整数×6(構造体サイズ 24 / 4 切り上げ)
; dwIndex : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; dwPhysAddrLen : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; bPhysAddr : BYTE (+8, 8byte)  varptr(st)+8 を基点に操作(8byte:入れ子/配列)
; dwAddr : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; dwType : DWORD (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global MIB_IPNETROW_W2K
    #field int dwIndex
    #field int dwPhysAddrLen
    #field byte bPhysAddr 8
    #field int dwAddr
    #field int dwType
#endstruct

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