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

WTSINFOEXW

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

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

フィールド

フィールドサイズx64x86説明
LevelDWORD4+0+0Dataに格納される情報のレベルを示す値。
DataWTSINFOEX_LEVEL_W224+8+8指定レベルの拡張セッション情報(Unicode)を含む共用体。

各言語での定義

#include <windows.h>

// WTSINFOEX_LEVEL1_W  (x64 224 / x86 224 バイト)
typedef struct WTSINFOEX_LEVEL1_W {
    DWORD SessionId;
    WTS_CONNECTSTATE_CLASS SessionState;
    INT SessionFlags;
    WCHAR WinStationName[33];
    WCHAR UserName[21];
    WCHAR DomainName[18];
    LONGLONG LogonTime;
    LONGLONG ConnectTime;
    LONGLONG DisconnectTime;
    LONGLONG LastInputTime;
    LONGLONG CurrentTime;
    DWORD IncomingBytes;
    DWORD OutgoingBytes;
    DWORD IncomingFrames;
    DWORD OutgoingFrames;
    DWORD IncomingCompressedBytes;
    DWORD OutgoingCompressedBytes;
} WTSINFOEX_LEVEL1_W;

// WTSINFOEX_LEVEL_W  (x64 224 / x86 224 バイト)
typedef struct WTSINFOEX_LEVEL_W {
    WTSINFOEX_LEVEL1_W WTSInfoExLevel1;
} WTSINFOEX_LEVEL_W;

// WTSINFOEXW  (x64 232 / x86 232 バイト)
typedef struct WTSINFOEXW {
    DWORD Level;
    WTSINFOEX_LEVEL_W Data;
} WTSINFOEXW;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WTSINFOEX_LEVEL1_W
{
    public uint SessionId;
    public int SessionState;
    public int SessionFlags;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 33)] public string WinStationName;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 21)] public string UserName;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 18)] public string DomainName;
    public long LogonTime;
    public long ConnectTime;
    public long DisconnectTime;
    public long LastInputTime;
    public long CurrentTime;
    public uint IncomingBytes;
    public uint OutgoingBytes;
    public uint IncomingFrames;
    public uint OutgoingFrames;
    public uint IncomingCompressedBytes;
    public uint OutgoingCompressedBytes;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WTSINFOEX_LEVEL_W
{
    public WTSINFOEX_LEVEL1_W WTSInfoExLevel1;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WTSINFOEXW
{
    public uint Level;
    public WTSINFOEX_LEVEL_W Data;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WTSINFOEX_LEVEL1_W
    Public SessionId As UInteger
    Public SessionState As Integer
    Public SessionFlags As Integer
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=33)> Public WinStationName As String
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=21)> Public UserName As String
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=18)> Public DomainName As String
    Public LogonTime As Long
    Public ConnectTime As Long
    Public DisconnectTime As Long
    Public LastInputTime As Long
    Public CurrentTime As Long
    Public IncomingBytes As UInteger
    Public OutgoingBytes As UInteger
    Public IncomingFrames As UInteger
    Public OutgoingFrames As UInteger
    Public IncomingCompressedBytes As UInteger
    Public OutgoingCompressedBytes As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WTSINFOEX_LEVEL_W
    Public WTSInfoExLevel1 As WTSINFOEX_LEVEL1_W
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WTSINFOEXW
    Public Level As UInteger
    Public Data As WTSINFOEX_LEVEL_W
End Structure
import ctypes
from ctypes import wintypes

class WTSINFOEX_LEVEL1_W(ctypes.Structure):
    _fields_ = [
        ("SessionId", wintypes.DWORD),
        ("SessionState", ctypes.c_int),
        ("SessionFlags", ctypes.c_int),
        ("WinStationName", ctypes.c_wchar * 33),
        ("UserName", ctypes.c_wchar * 21),
        ("DomainName", ctypes.c_wchar * 18),
        ("LogonTime", ctypes.c_longlong),
        ("ConnectTime", ctypes.c_longlong),
        ("DisconnectTime", ctypes.c_longlong),
        ("LastInputTime", ctypes.c_longlong),
        ("CurrentTime", ctypes.c_longlong),
        ("IncomingBytes", wintypes.DWORD),
        ("OutgoingBytes", wintypes.DWORD),
        ("IncomingFrames", wintypes.DWORD),
        ("OutgoingFrames", wintypes.DWORD),
        ("IncomingCompressedBytes", wintypes.DWORD),
        ("OutgoingCompressedBytes", wintypes.DWORD),
    ]

class WTSINFOEX_LEVEL_W(ctypes.Structure):
    _fields_ = [
        ("WTSInfoExLevel1", WTSINFOEX_LEVEL1_W),
    ]

class WTSINFOEXW(ctypes.Structure):
    _fields_ = [
        ("Level", wintypes.DWORD),
        ("Data", WTSINFOEX_LEVEL_W),
    ]
#[repr(C)]
pub struct WTSINFOEX_LEVEL1_W {
    pub SessionId: u32,
    pub SessionState: i32,
    pub SessionFlags: i32,
    pub WinStationName: [u16; 33],
    pub UserName: [u16; 21],
    pub DomainName: [u16; 18],
    pub LogonTime: i64,
    pub ConnectTime: i64,
    pub DisconnectTime: i64,
    pub LastInputTime: i64,
    pub CurrentTime: i64,
    pub IncomingBytes: u32,
    pub OutgoingBytes: u32,
    pub IncomingFrames: u32,
    pub OutgoingFrames: u32,
    pub IncomingCompressedBytes: u32,
    pub OutgoingCompressedBytes: u32,
}

#[repr(C)]
pub struct WTSINFOEX_LEVEL_W {
    pub WTSInfoExLevel1: WTSINFOEX_LEVEL1_W,
}

#[repr(C)]
pub struct WTSINFOEXW {
    pub Level: u32,
    pub Data: WTSINFOEX_LEVEL_W,
}
import "golang.org/x/sys/windows"

type WTSINFOEX_LEVEL1_W struct {
	SessionId uint32
	SessionState int32
	SessionFlags int32
	WinStationName [33]uint16
	UserName [21]uint16
	DomainName [18]uint16
	LogonTime int64
	ConnectTime int64
	DisconnectTime int64
	LastInputTime int64
	CurrentTime int64
	IncomingBytes uint32
	OutgoingBytes uint32
	IncomingFrames uint32
	OutgoingFrames uint32
	IncomingCompressedBytes uint32
	OutgoingCompressedBytes uint32
}

type WTSINFOEX_LEVEL_W struct {
	WTSInfoExLevel1 WTSINFOEX_LEVEL1_W
}

type WTSINFOEXW struct {
	Level uint32
	Data WTSINFOEX_LEVEL_W
}
type
  WTSINFOEX_LEVEL1_W = record
    SessionId: DWORD;
    SessionState: Integer;
    SessionFlags: Integer;
    WinStationName: array[0..32] of WideChar;
    UserName: array[0..20] of WideChar;
    DomainName: array[0..17] of WideChar;
    LogonTime: Int64;
    ConnectTime: Int64;
    DisconnectTime: Int64;
    LastInputTime: Int64;
    CurrentTime: Int64;
    IncomingBytes: DWORD;
    OutgoingBytes: DWORD;
    IncomingFrames: DWORD;
    OutgoingFrames: DWORD;
    IncomingCompressedBytes: DWORD;
    OutgoingCompressedBytes: DWORD;
  end;

  WTSINFOEX_LEVEL_W = record
    WTSInfoExLevel1: WTSINFOEX_LEVEL1_W;
  end;

  WTSINFOEXW = record
    Level: DWORD;
    Data: WTSINFOEX_LEVEL_W;
  end;
const WTSINFOEX_LEVEL1_W = extern struct {
    SessionId: u32,
    SessionState: i32,
    SessionFlags: i32,
    WinStationName: [33]u16,
    UserName: [21]u16,
    DomainName: [18]u16,
    LogonTime: i64,
    ConnectTime: i64,
    DisconnectTime: i64,
    LastInputTime: i64,
    CurrentTime: i64,
    IncomingBytes: u32,
    OutgoingBytes: u32,
    IncomingFrames: u32,
    OutgoingFrames: u32,
    IncomingCompressedBytes: u32,
    OutgoingCompressedBytes: u32,
};

const WTSINFOEX_LEVEL_W = extern struct {
    WTSInfoExLevel1: WTSINFOEX_LEVEL1_W,
};

const WTSINFOEXW = extern struct {
    Level: u32,
    Data: WTSINFOEX_LEVEL_W,
};
type
  WTSINFOEX_LEVEL1_W {.bycopy.} = object
    SessionId: uint32
    SessionState: int32
    SessionFlags: int32
    WinStationName: array[33, uint16]
    UserName: array[21, uint16]
    DomainName: array[18, uint16]
    LogonTime: int64
    ConnectTime: int64
    DisconnectTime: int64
    LastInputTime: int64
    CurrentTime: int64
    IncomingBytes: uint32
    OutgoingBytes: uint32
    IncomingFrames: uint32
    OutgoingFrames: uint32
    IncomingCompressedBytes: uint32
    OutgoingCompressedBytes: uint32

  WTSINFOEX_LEVEL_W {.bycopy.} = object
    WTSInfoExLevel1: WTSINFOEX_LEVEL1_W

  WTSINFOEXW {.bycopy.} = object
    Level: uint32
    Data: WTSINFOEX_LEVEL_W
struct WTSINFOEX_LEVEL1_W
{
    uint SessionId;
    int SessionState;
    int SessionFlags;
    wchar[33] WinStationName;
    wchar[21] UserName;
    wchar[18] DomainName;
    long LogonTime;
    long ConnectTime;
    long DisconnectTime;
    long LastInputTime;
    long CurrentTime;
    uint IncomingBytes;
    uint OutgoingBytes;
    uint IncomingFrames;
    uint OutgoingFrames;
    uint IncomingCompressedBytes;
    uint OutgoingCompressedBytes;
}

struct WTSINFOEX_LEVEL_W
{
    WTSINFOEX_LEVEL1_W WTSInfoExLevel1;
}

struct WTSINFOEXW
{
    uint Level;
    WTSINFOEX_LEVEL_W Data;
}

HSP用 定義

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

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

stdim st, WTSINFOEXW        ; NSTRUCT 変数を確保
st->Level = 100
mes "Level=" + st->Level
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。