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

WTS_SESSION_ADDRESS

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

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

フィールド

フィールドサイズx64x86説明
AddressFamilyDWORD4+0+0アドレスファミリ(AF_INET等)を示す値。
AddressBYTE20+4+4セッションのネットワークアドレス。バイト配列。

各言語での定義

#include <windows.h>

// WTS_SESSION_ADDRESS  (x64 24 / x86 24 バイト)
typedef struct WTS_SESSION_ADDRESS {
    DWORD AddressFamily;
    BYTE Address[20];
} WTS_SESSION_ADDRESS;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WTS_SESSION_ADDRESS
{
    public uint AddressFamily;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)] public byte[] Address;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WTS_SESSION_ADDRESS
    Public AddressFamily As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=20)> Public Address() As Byte
End Structure
import ctypes
from ctypes import wintypes

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

type WTS_SESSION_ADDRESS struct {
	AddressFamily uint32
	Address [20]byte
}
type
  WTS_SESSION_ADDRESS = record
    AddressFamily: DWORD;
    Address: array[0..19] of Byte;
  end;
const WTS_SESSION_ADDRESS = extern struct {
    AddressFamily: u32,
    Address: [20]u8,
};
type
  WTS_SESSION_ADDRESS {.bycopy.} = object
    AddressFamily: uint32
    Address: array[20, uint8]
struct WTS_SESSION_ADDRESS
{
    uint AddressFamily;
    ubyte[20] Address;
}

HSP用 定義

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

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

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