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

WTSINFOEXA

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

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

フィールド

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

各言語での定義

#include <windows.h>

// WTSINFOEX_LEVEL1_A  (x64 152 / x86 152 バイト)
typedef struct WTSINFOEX_LEVEL1_A {
    DWORD SessionId;
    WTS_CONNECTSTATE_CLASS SessionState;
    INT SessionFlags;
    CHAR WinStationName[33];
    CHAR UserName[21];
    CHAR 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_A;

// WTSINFOEX_LEVEL_A  (x64 152 / x86 152 バイト)
typedef struct WTSINFOEX_LEVEL_A {
    WTSINFOEX_LEVEL1_A WTSInfoExLevel1;
} WTSINFOEX_LEVEL_A;

// WTSINFOEXA  (x64 160 / x86 160 バイト)
typedef struct WTSINFOEXA {
    DWORD Level;
    WTSINFOEX_LEVEL_A Data;
} WTSINFOEXA;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WTSINFOEX_LEVEL1_A
{
    public uint SessionId;
    public int SessionState;
    public int SessionFlags;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 33)] public sbyte[] WinStationName;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 21)] public sbyte[] UserName;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 18)] public sbyte[] 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_A
{
    public WTSINFOEX_LEVEL1_A WTSInfoExLevel1;
}

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

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WTSINFOEX_LEVEL1_A
    Public SessionId As UInteger
    Public SessionState As Integer
    Public SessionFlags As Integer
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=33)> Public WinStationName() As SByte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=21)> Public UserName() As SByte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=18)> Public DomainName() As SByte
    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_A
    Public WTSInfoExLevel1 As WTSINFOEX_LEVEL1_A
End Structure

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

class WTSINFOEX_LEVEL1_A(ctypes.Structure):
    _fields_ = [
        ("SessionId", wintypes.DWORD),
        ("SessionState", ctypes.c_int),
        ("SessionFlags", ctypes.c_int),
        ("WinStationName", ctypes.c_byte * 33),
        ("UserName", ctypes.c_byte * 21),
        ("DomainName", ctypes.c_byte * 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_A(ctypes.Structure):
    _fields_ = [
        ("WTSInfoExLevel1", WTSINFOEX_LEVEL1_A),
    ]

class WTSINFOEXA(ctypes.Structure):
    _fields_ = [
        ("Level", wintypes.DWORD),
        ("Data", WTSINFOEX_LEVEL_A),
    ]
#[repr(C)]
pub struct WTSINFOEX_LEVEL1_A {
    pub SessionId: u32,
    pub SessionState: i32,
    pub SessionFlags: i32,
    pub WinStationName: [i8; 33],
    pub UserName: [i8; 21],
    pub DomainName: [i8; 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_A {
    pub WTSInfoExLevel1: WTSINFOEX_LEVEL1_A,
}

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

type WTSINFOEX_LEVEL1_A struct {
	SessionId uint32
	SessionState int32
	SessionFlags int32
	WinStationName [33]int8
	UserName [21]int8
	DomainName [18]int8
	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_A struct {
	WTSInfoExLevel1 WTSINFOEX_LEVEL1_A
}

type WTSINFOEXA struct {
	Level uint32
	Data WTSINFOEX_LEVEL_A
}
type
  WTSINFOEX_LEVEL1_A = record
    SessionId: DWORD;
    SessionState: Integer;
    SessionFlags: Integer;
    WinStationName: array[0..32] of Shortint;
    UserName: array[0..20] of Shortint;
    DomainName: array[0..17] of Shortint;
    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_A = record
    WTSInfoExLevel1: WTSINFOEX_LEVEL1_A;
  end;

  WTSINFOEXA = record
    Level: DWORD;
    Data: WTSINFOEX_LEVEL_A;
  end;
const WTSINFOEX_LEVEL1_A = extern struct {
    SessionId: u32,
    SessionState: i32,
    SessionFlags: i32,
    WinStationName: [33]i8,
    UserName: [21]i8,
    DomainName: [18]i8,
    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_A = extern struct {
    WTSInfoExLevel1: WTSINFOEX_LEVEL1_A,
};

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

  WTSINFOEX_LEVEL_A {.bycopy.} = object
    WTSInfoExLevel1: WTSINFOEX_LEVEL1_A

  WTSINFOEXA {.bycopy.} = object
    Level: uint32
    Data: WTSINFOEX_LEVEL_A
struct WTSINFOEX_LEVEL1_A
{
    uint SessionId;
    int SessionState;
    int SessionFlags;
    byte[33] WinStationName;
    byte[21] UserName;
    byte[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_A
{
    WTSINFOEX_LEVEL1_A WTSInfoExLevel1;
}

struct WTSINFOEXA
{
    uint Level;
    WTSINFOEX_LEVEL_A Data;
}

HSP用 定義

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

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

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