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

IF_PHYSICAL_ADDRESS_LH

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

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

フィールド

フィールドサイズx64x86説明
LengthWORD2+0+0Address内の有効な物理アドレスの長さ(バイト数)である。
AddressBYTE32+2+2物理(MAC)アドレスを保持する固定長バイト配列である。

各言語での定義

#include <windows.h>

// IF_PHYSICAL_ADDRESS_LH  (x64 34 / x86 34 バイト)
typedef struct IF_PHYSICAL_ADDRESS_LH {
    WORD Length;
    BYTE Address[32];
} IF_PHYSICAL_ADDRESS_LH;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct IF_PHYSICAL_ADDRESS_LH
{
    public ushort Length;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public byte[] Address;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure IF_PHYSICAL_ADDRESS_LH
    Public Length As UShort
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=32)> Public Address() As Byte
End Structure
import ctypes
from ctypes import wintypes

class IF_PHYSICAL_ADDRESS_LH(ctypes.Structure):
    _fields_ = [
        ("Length", ctypes.c_ushort),
        ("Address", ctypes.c_ubyte * 32),
    ]
#[repr(C)]
pub struct IF_PHYSICAL_ADDRESS_LH {
    pub Length: u16,
    pub Address: [u8; 32],
}
import "golang.org/x/sys/windows"

type IF_PHYSICAL_ADDRESS_LH struct {
	Length uint16
	Address [32]byte
}
type
  IF_PHYSICAL_ADDRESS_LH = record
    Length: Word;
    Address: array[0..31] of Byte;
  end;
const IF_PHYSICAL_ADDRESS_LH = extern struct {
    Length: u16,
    Address: [32]u8,
};
type
  IF_PHYSICAL_ADDRESS_LH {.bycopy.} = object
    Length: uint16
    Address: array[32, uint8]
struct IF_PHYSICAL_ADDRESS_LH
{
    ushort Length;
    ubyte[32] Address;
}

HSP用 定義

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

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

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