ホーム › System.RemoteDesktop › WTSINFOW
WTSINFOW
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| State | WTS_CONNECTSTATE_CLASS | 4 | +0 | +0 | セッションの接続状態を示す列挙値。 |
| SessionId | DWORD | 4 | +4 | +4 | セッションを識別する識別子。 |
| IncomingBytes | DWORD | 4 | +8 | +8 | 受信した総バイト数。 |
| OutgoingBytes | DWORD | 4 | +12 | +12 | 送信した総バイト数。 |
| IncomingFrames | DWORD | 4 | +16 | +16 | 受信した総フレーム数。 |
| OutgoingFrames | DWORD | 4 | +20 | +20 | 送信した総フレーム数。 |
| IncomingCompressedBytes | DWORD | 4 | +24 | +24 | 圧縮された受信バイト数。 |
| OutgoingCompressedBytes | DWORD | 4 | +28 | +28 | 圧縮された送信バイト数。 |
| WinStationName | WCHAR | 64 | +32 | +32 | WinStation名(Unicode)。 |
| Domain | WCHAR | 34 | +96 | +96 | ドメイン名(Unicode)。 |
| UserName | WCHAR | 42 | +130 | +130 | ユーザー名(Unicode)。 |
| ConnectTime | LONGLONG | 8 | +176 | +176 | 接続時刻。FILETIME相当の64ビット値。 |
| DisconnectTime | LONGLONG | 8 | +184 | +184 | 切断時刻。FILETIME相当の64ビット値。 |
| LastInputTime | LONGLONG | 8 | +192 | +192 | 最後の入力時刻。FILETIME相当の64ビット値。 |
| LogonTime | LONGLONG | 8 | +200 | +200 | ログオン時刻。FILETIME相当の64ビット値。 |
| CurrentTime | LONGLONG | 8 | +208 | +208 | 現在時刻。FILETIME相当の64ビット値。 |
各言語での定義
#include <windows.h>
// WTSINFOW (x64 216 / x86 216 バイト)
typedef struct WTSINFOW {
WTS_CONNECTSTATE_CLASS State;
DWORD SessionId;
DWORD IncomingBytes;
DWORD OutgoingBytes;
DWORD IncomingFrames;
DWORD OutgoingFrames;
DWORD IncomingCompressedBytes;
DWORD OutgoingCompressedBytes;
WCHAR WinStationName[32];
WCHAR Domain[17];
WCHAR UserName[21];
LONGLONG ConnectTime;
LONGLONG DisconnectTime;
LONGLONG LastInputTime;
LONGLONG LogonTime;
LONGLONG CurrentTime;
} WTSINFOW;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WTSINFOW
{
public int State;
public uint SessionId;
public uint IncomingBytes;
public uint OutgoingBytes;
public uint IncomingFrames;
public uint OutgoingFrames;
public uint IncomingCompressedBytes;
public uint OutgoingCompressedBytes;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] public string WinStationName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 17)] public string Domain;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 21)] public string UserName;
public long ConnectTime;
public long DisconnectTime;
public long LastInputTime;
public long LogonTime;
public long CurrentTime;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WTSINFOW
Public State As Integer
Public SessionId As UInteger
Public IncomingBytes As UInteger
Public OutgoingBytes As UInteger
Public IncomingFrames As UInteger
Public OutgoingFrames As UInteger
Public IncomingCompressedBytes As UInteger
Public OutgoingCompressedBytes As UInteger
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=32)> Public WinStationName As String
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=17)> Public Domain As String
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=21)> Public UserName As String
Public ConnectTime As Long
Public DisconnectTime As Long
Public LastInputTime As Long
Public LogonTime As Long
Public CurrentTime As Long
End Structureimport ctypes
from ctypes import wintypes
class WTSINFOW(ctypes.Structure):
_fields_ = [
("State", ctypes.c_int),
("SessionId", wintypes.DWORD),
("IncomingBytes", wintypes.DWORD),
("OutgoingBytes", wintypes.DWORD),
("IncomingFrames", wintypes.DWORD),
("OutgoingFrames", wintypes.DWORD),
("IncomingCompressedBytes", wintypes.DWORD),
("OutgoingCompressedBytes", wintypes.DWORD),
("WinStationName", ctypes.c_wchar * 32),
("Domain", ctypes.c_wchar * 17),
("UserName", ctypes.c_wchar * 21),
("ConnectTime", ctypes.c_longlong),
("DisconnectTime", ctypes.c_longlong),
("LastInputTime", ctypes.c_longlong),
("LogonTime", ctypes.c_longlong),
("CurrentTime", ctypes.c_longlong),
]#[repr(C)]
pub struct WTSINFOW {
pub State: i32,
pub SessionId: u32,
pub IncomingBytes: u32,
pub OutgoingBytes: u32,
pub IncomingFrames: u32,
pub OutgoingFrames: u32,
pub IncomingCompressedBytes: u32,
pub OutgoingCompressedBytes: u32,
pub WinStationName: [u16; 32],
pub Domain: [u16; 17],
pub UserName: [u16; 21],
pub ConnectTime: i64,
pub DisconnectTime: i64,
pub LastInputTime: i64,
pub LogonTime: i64,
pub CurrentTime: i64,
}import "golang.org/x/sys/windows"
type WTSINFOW struct {
State int32
SessionId uint32
IncomingBytes uint32
OutgoingBytes uint32
IncomingFrames uint32
OutgoingFrames uint32
IncomingCompressedBytes uint32
OutgoingCompressedBytes uint32
WinStationName [32]uint16
Domain [17]uint16
UserName [21]uint16
ConnectTime int64
DisconnectTime int64
LastInputTime int64
LogonTime int64
CurrentTime int64
}type
WTSINFOW = record
State: Integer;
SessionId: DWORD;
IncomingBytes: DWORD;
OutgoingBytes: DWORD;
IncomingFrames: DWORD;
OutgoingFrames: DWORD;
IncomingCompressedBytes: DWORD;
OutgoingCompressedBytes: DWORD;
WinStationName: array[0..31] of WideChar;
Domain: array[0..16] of WideChar;
UserName: array[0..20] of WideChar;
ConnectTime: Int64;
DisconnectTime: Int64;
LastInputTime: Int64;
LogonTime: Int64;
CurrentTime: Int64;
end;const WTSINFOW = extern struct {
State: i32,
SessionId: u32,
IncomingBytes: u32,
OutgoingBytes: u32,
IncomingFrames: u32,
OutgoingFrames: u32,
IncomingCompressedBytes: u32,
OutgoingCompressedBytes: u32,
WinStationName: [32]u16,
Domain: [17]u16,
UserName: [21]u16,
ConnectTime: i64,
DisconnectTime: i64,
LastInputTime: i64,
LogonTime: i64,
CurrentTime: i64,
};type
WTSINFOW {.bycopy.} = object
State: int32
SessionId: uint32
IncomingBytes: uint32
OutgoingBytes: uint32
IncomingFrames: uint32
OutgoingFrames: uint32
IncomingCompressedBytes: uint32
OutgoingCompressedBytes: uint32
WinStationName: array[32, uint16]
Domain: array[17, uint16]
UserName: array[21, uint16]
ConnectTime: int64
DisconnectTime: int64
LastInputTime: int64
LogonTime: int64
CurrentTime: int64struct WTSINFOW
{
int State;
uint SessionId;
uint IncomingBytes;
uint OutgoingBytes;
uint IncomingFrames;
uint OutgoingFrames;
uint IncomingCompressedBytes;
uint OutgoingCompressedBytes;
wchar[32] WinStationName;
wchar[17] Domain;
wchar[21] UserName;
long ConnectTime;
long DisconnectTime;
long LastInputTime;
long LogonTime;
long CurrentTime;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; WTSINFOW サイズ: 216 バイト(x64)
dim st, 54 ; 4byte整数×54(構造体サイズ 216 / 4 切り上げ)
; State : WTS_CONNECTSTATE_CLASS (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; SessionId : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; IncomingBytes : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; OutgoingBytes : DWORD (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; IncomingFrames : DWORD (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; OutgoingFrames : DWORD (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; IncomingCompressedBytes : DWORD (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; OutgoingCompressedBytes : DWORD (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; WinStationName : WCHAR (+32, 64byte) varptr(st)+32 を基点に操作(64byte:入れ子/配列)
; Domain : WCHAR (+96, 34byte) varptr(st)+96 を基点に操作(34byte:入れ子/配列)
; UserName : WCHAR (+130, 42byte) varptr(st)+130 を基点に操作(42byte:入れ子/配列)
; ConnectTime : LONGLONG (+176, 8byte) qpoke st,176,値 / qpeek(st,176) ※IronHSPのみ。3.7/3.8は lpoke st,176,下位 : lpoke st,180,上位
; DisconnectTime : LONGLONG (+184, 8byte) qpoke st,184,値 / qpeek(st,184) ※IronHSPのみ。3.7/3.8は lpoke st,184,下位 : lpoke st,188,上位
; LastInputTime : LONGLONG (+192, 8byte) qpoke st,192,値 / qpeek(st,192) ※IronHSPのみ。3.7/3.8は lpoke st,192,下位 : lpoke st,196,上位
; LogonTime : LONGLONG (+200, 8byte) qpoke st,200,値 / qpeek(st,200) ※IronHSPのみ。3.7/3.8は lpoke st,200,下位 : lpoke st,204,上位
; CurrentTime : LONGLONG (+208, 8byte) qpoke st,208,値 / qpeek(st,208) ※IronHSPのみ。3.7/3.8は lpoke st,208,下位 : lpoke st,212,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global WTSINFOW
#field int State
#field int SessionId
#field int IncomingBytes
#field int OutgoingBytes
#field int IncomingFrames
#field int OutgoingFrames
#field int IncomingCompressedBytes
#field int OutgoingCompressedBytes
#field wchar WinStationName 32
#field wchar Domain 17
#field wchar UserName 21
#field int64 ConnectTime
#field int64 DisconnectTime
#field int64 LastInputTime
#field int64 LogonTime
#field int64 CurrentTime
#endstruct
stdim st, WTSINFOW ; NSTRUCT 変数を確保
st->State = 100
mes "State=" + st->State