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

IP6_ADDRESS

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

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

フィールド

フィールドサイズx64x86説明
IP6DwordDWORD16+0+0IPv6アドレスを4個の32ビット値として参照する配列ビュー。
IP6WordWORD16+0+0IPv6アドレスを8個の16ビット値として参照する配列ビュー。
IP6ByteBYTE16+0+0IPv6アドレスを16個のバイト値として参照する配列ビュー。

各言語での定義

#include <windows.h>

// IP6_ADDRESS  (x64 16 / x86 16 バイト)
typedef struct IP6_ADDRESS {
    DWORD IP6Dword[4];
    WORD IP6Word[8];
    BYTE IP6Byte[16];
} IP6_ADDRESS;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct IP6_ADDRESS
{
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public uint[] IP6Dword;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public ushort[] IP6Word;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] IP6Byte;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure IP6_ADDRESS
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=4)> Public IP6Dword() As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=8)> Public IP6Word() As UShort
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=16)> Public IP6Byte() As Byte
End Structure
import ctypes
from ctypes import wintypes

class IP6_ADDRESS(ctypes.Structure):
    _fields_ = [
        ("IP6Dword", wintypes.DWORD * 4),
        ("IP6Word", ctypes.c_ushort * 8),
        ("IP6Byte", ctypes.c_ubyte * 16),
    ]
#[repr(C)]
pub struct IP6_ADDRESS {
    pub IP6Dword: [u32; 4],
    pub IP6Word: [u16; 8],
    pub IP6Byte: [u8; 16],
}
import "golang.org/x/sys/windows"

type IP6_ADDRESS struct {
	IP6Dword [4]uint32
	IP6Word [8]uint16
	IP6Byte [16]byte
}
type
  IP6_ADDRESS = record
    IP6Dword: array[0..3] of DWORD;
    IP6Word: array[0..7] of Word;
    IP6Byte: array[0..15] of Byte;
  end;
const IP6_ADDRESS = extern struct {
    IP6Dword: [4]u32,
    IP6Word: [8]u16,
    IP6Byte: [16]u8,
};
type
  IP6_ADDRESS {.bycopy.} = object
    IP6Dword: array[4, uint32]
    IP6Word: array[8, uint16]
    IP6Byte: array[16, uint8]
struct IP6_ADDRESS
{
    uint[4] IP6Dword;
    ushort[8] IP6Word;
    ubyte[16] IP6Byte;
}

HSP用 定義

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

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

stdim st, IP6_ADDRESS        ; NSTRUCT 変数を確保