Win32 API 日本語リファレンス
ホームStorage.VirtualDiskService › VDS_IPADDRESS

VDS_IPADDRESS

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

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

フィールド

フィールドサイズx64x86説明
typeVDS_IPADDRESS_TYPE4+0+0IPアドレスの形式(IPv4/IPv6/テキスト等)を示すVDS_IPADDRESS_TYPE列挙値。
ipv4AddressDWORD4+4+4IPv4アドレスを32ビット整数で格納する。type がIPv4のとき有効。
ipv6AddressBYTE16+8+8IPv6アドレスを表す16バイトの固定長配列。type がIPv6のとき有効。
ulIpv6FlowInfoDWORD4+24+24IPv6のフローラベル情報を格納する。
ulIpv6ScopeIdDWORD4+28+28IPv6のスコープID(インターフェイス識別)を格納する。
wszTextAddressWCHAR514+32+32アドレスのテキスト表現を格納するワイド文字配列。
ulPortDWORD4+548+548TCP/UDPポート番号を格納する。

各言語での定義

#include <windows.h>

// VDS_IPADDRESS  (x64 552 / x86 552 バイト)
typedef struct VDS_IPADDRESS {
    VDS_IPADDRESS_TYPE type;
    DWORD ipv4Address;
    BYTE ipv6Address[16];
    DWORD ulIpv6FlowInfo;
    DWORD ulIpv6ScopeId;
    WCHAR wszTextAddress[257];
    DWORD ulPort;
} VDS_IPADDRESS;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct VDS_IPADDRESS
{
    public int type;
    public uint ipv4Address;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] ipv6Address;
    public uint ulIpv6FlowInfo;
    public uint ulIpv6ScopeId;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 257)] public string wszTextAddress;
    public uint ulPort;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure VDS_IPADDRESS
    Public type As Integer
    Public ipv4Address As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=16)> Public ipv6Address() As Byte
    Public ulIpv6FlowInfo As UInteger
    Public ulIpv6ScopeId As UInteger
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=257)> Public wszTextAddress As String
    Public ulPort As UInteger
End Structure
import ctypes
from ctypes import wintypes

class VDS_IPADDRESS(ctypes.Structure):
    _fields_ = [
        ("type", ctypes.c_int),
        ("ipv4Address", wintypes.DWORD),
        ("ipv6Address", ctypes.c_ubyte * 16),
        ("ulIpv6FlowInfo", wintypes.DWORD),
        ("ulIpv6ScopeId", wintypes.DWORD),
        ("wszTextAddress", ctypes.c_wchar * 257),
        ("ulPort", wintypes.DWORD),
    ]
#[repr(C)]
pub struct VDS_IPADDRESS {
    pub type: i32,
    pub ipv4Address: u32,
    pub ipv6Address: [u8; 16],
    pub ulIpv6FlowInfo: u32,
    pub ulIpv6ScopeId: u32,
    pub wszTextAddress: [u16; 257],
    pub ulPort: u32,
}
import "golang.org/x/sys/windows"

type VDS_IPADDRESS struct {
	type int32
	ipv4Address uint32
	ipv6Address [16]byte
	ulIpv6FlowInfo uint32
	ulIpv6ScopeId uint32
	wszTextAddress [257]uint16
	ulPort uint32
}
type
  VDS_IPADDRESS = record
    type: Integer;
    ipv4Address: DWORD;
    ipv6Address: array[0..15] of Byte;
    ulIpv6FlowInfo: DWORD;
    ulIpv6ScopeId: DWORD;
    wszTextAddress: array[0..256] of WideChar;
    ulPort: DWORD;
  end;
const VDS_IPADDRESS = extern struct {
    type: i32,
    ipv4Address: u32,
    ipv6Address: [16]u8,
    ulIpv6FlowInfo: u32,
    ulIpv6ScopeId: u32,
    wszTextAddress: [257]u16,
    ulPort: u32,
};
type
  VDS_IPADDRESS {.bycopy.} = object
    type: int32
    ipv4Address: uint32
    ipv6Address: array[16, uint8]
    ulIpv6FlowInfo: uint32
    ulIpv6ScopeId: uint32
    wszTextAddress: array[257, uint16]
    ulPort: uint32
struct VDS_IPADDRESS
{
    int type;
    uint ipv4Address;
    ubyte[16] ipv6Address;
    uint ulIpv6FlowInfo;
    uint ulIpv6ScopeId;
    wchar[257] wszTextAddress;
    uint ulPort;
}

HSP用 定義

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

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

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