Win32 API 日本語リファレンス
ホームSystem.RemoteDesktop › WTSSBX_IP_ADDRESS

WTSSBX_IP_ADDRESS

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

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

フィールド

フィールドサイズx64x86説明
AddressFamilyWTSSBX_ADDRESS_FAMILY4+0+0アドレスファミリを示すWTSSBX列挙値。
AddressBYTE16+4+4IPアドレスのバイト配列。
PortNumberWORD2+20+20ポート番号。
dwScopeDWORD4+24+24アドレスのスコープ識別子。

各言語での定義

#include <windows.h>

// WTSSBX_IP_ADDRESS  (x64 28 / x86 28 バイト)
typedef struct WTSSBX_IP_ADDRESS {
    WTSSBX_ADDRESS_FAMILY AddressFamily;
    BYTE Address[16];
    WORD PortNumber;
    DWORD dwScope;
} WTSSBX_IP_ADDRESS;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WTSSBX_IP_ADDRESS
{
    public int AddressFamily;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] Address;
    public ushort PortNumber;
    public uint dwScope;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WTSSBX_IP_ADDRESS
    Public AddressFamily As Integer
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=16)> Public Address() As Byte
    Public PortNumber As UShort
    Public dwScope As UInteger
End Structure
import ctypes
from ctypes import wintypes

class WTSSBX_IP_ADDRESS(ctypes.Structure):
    _fields_ = [
        ("AddressFamily", ctypes.c_int),
        ("Address", ctypes.c_ubyte * 16),
        ("PortNumber", ctypes.c_ushort),
        ("dwScope", wintypes.DWORD),
    ]
#[repr(C)]
pub struct WTSSBX_IP_ADDRESS {
    pub AddressFamily: i32,
    pub Address: [u8; 16],
    pub PortNumber: u16,
    pub dwScope: u32,
}
import "golang.org/x/sys/windows"

type WTSSBX_IP_ADDRESS struct {
	AddressFamily int32
	Address [16]byte
	PortNumber uint16
	dwScope uint32
}
type
  WTSSBX_IP_ADDRESS = record
    AddressFamily: Integer;
    Address: array[0..15] of Byte;
    PortNumber: Word;
    dwScope: DWORD;
  end;
const WTSSBX_IP_ADDRESS = extern struct {
    AddressFamily: i32,
    Address: [16]u8,
    PortNumber: u16,
    dwScope: u32,
};
type
  WTSSBX_IP_ADDRESS {.bycopy.} = object
    AddressFamily: int32
    Address: array[16, uint8]
    PortNumber: uint16
    dwScope: uint32
struct WTSSBX_IP_ADDRESS
{
    int AddressFamily;
    ubyte[16] Address;
    ushort PortNumber;
    uint dwScope;
}

HSP用 定義

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

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

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