ホーム › System.RemoteDesktop › WTSINFOW
WTSINFOW
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| State | WTS_CONNECTSTATE_CLASS | 4 | +0 | +0 | セッションの現在の接続状態を示す WTS_CONNECTSTATE_CLASS 列挙型の値です。 |
| SessionId | DWORD | 4 | +4 | +4 | セッション識別子です。 |
| IncomingBytes | DWORD | 4 | +8 | +8 | クライアントからサーバーへの非圧縮のリモート デスクトップ プロトコル (RDP) データです。 |
| OutgoingBytes | DWORD | 4 | +12 | +12 | サーバーからクライアントへの非圧縮の RDP データです。 |
| IncomingFrames | DWORD | 4 | +16 | +16 | クライアントが接続してから、クライアントからサーバーへ送信された RDP データのフレーム数です。 |
| OutgoingFrames | DWORD | 4 | +20 | +20 | クライアントが接続してから、サーバーからクライアントへ送信された RDP データのフレーム数です。 |
| IncomingCompressedBytes | DWORD | 4 | +24 | +24 | クライアントからサーバーへの圧縮された RDP データです。 |
| OutgoingCompressedBytes | DWORD | 4 | +28 | +28 | サーバーからクライアントへの圧縮された RDP データです。 |
| WinStationName | WCHAR | 64 | +32 | +32 | セッションの WinStation の名前を格納する null 終端文字列です。 |
| Domain | WCHAR | 34 | +96 | +96 | ユーザーが属するドメインの名前を格納する null 終端文字列です。 |
| UserName | WCHAR | 42 | +130 | +130 | セッションを所有するユーザーの名前を格納する null 終端文字列です。 |
| ConnectTime | LONGLONG | 8 | +176 | +176 | 直近のクライアント接続時刻です。 |
| DisconnectTime | LONGLONG | 8 | +184 | +184 | 最後のクライアント切断時刻です。 |
| LastInputTime | LONGLONG | 8 | +192 | +192 | セッションで最後にユーザー入力があった時刻です。 |
| LogonTime | LONGLONG | 8 | +200 | +200 | ユーザーがセッションにログオンした時刻です。 |
| CurrentTime | LONGLONG | 8 | +208 | +208 | WTSINFO データ構造体が呼び出された時刻です。 |
公式ドキュメント
リモート デスクトップ サービス セッションに関する情報を格納します。
解説(Remarks)
メモ
wtsapi32.h ヘッダーは、UNICODE プリプロセッサ定数の定義に基づいて、この関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして WTSINFO を定義します。エンコードに依存しないこのエイリアスと、エンコードに依存しないコードではないものを混在して使用すると、不一致が生じ、コンパイル エラーや実行時エラーの原因になることがあります。詳細については、「Conventions for Function Prototypes」を参照してください。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での定義
#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