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

IPNG_ADDRESS

共用体
サイズx64: 16 バイト / x86: 16 バイト

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

フィールド

フィールドサイズx64x86説明
IpAddrV4DWORD4+0+0IPv4アドレスをDWORDで保持する共用体メンバである。
IpAddrV6BYTE16+0+0IPv6アドレスを16バイトの配列で保持する共用体メンバである。

各言語での定義

#include <windows.h>

// IPNG_ADDRESS  (x64 16 / x86 16 バイト)
typedef struct IPNG_ADDRESS {
    DWORD IpAddrV4;
    BYTE IpAddrV6[16];
} IPNG_ADDRESS;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct IPNG_ADDRESS
{
    public uint IpAddrV4;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] IpAddrV6;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure IPNG_ADDRESS
    Public IpAddrV4 As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=16)> Public IpAddrV6() As Byte
End Structure
import ctypes
from ctypes import wintypes

class IPNG_ADDRESS(ctypes.Structure):
    _fields_ = [
        ("IpAddrV4", wintypes.DWORD),
        ("IpAddrV6", ctypes.c_ubyte * 16),
    ]
#[repr(C)]
pub struct IPNG_ADDRESS {
    pub IpAddrV4: u32,
    pub IpAddrV6: [u8; 16],
}
import "golang.org/x/sys/windows"

type IPNG_ADDRESS struct {
	IpAddrV4 uint32
	IpAddrV6 [16]byte
}
type
  IPNG_ADDRESS = record
    IpAddrV4: DWORD;
    IpAddrV6: array[0..15] of Byte;
  end;
const IPNG_ADDRESS = extern struct {
    IpAddrV4: u32,
    IpAddrV6: [16]u8,
};
type
  IPNG_ADDRESS {.bycopy.} = object
    IpAddrV4: uint32
    IpAddrV6: array[16, uint8]
struct IPNG_ADDRESS
{
    uint IpAddrV4;
    ubyte[16] IpAddrV6;
}

HSP用 定義

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

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

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