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

WTSUSERCONFIGA

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

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

フィールド

フィールドサイズx64x86説明
SourceDWORD4+0+0WTS_CONFIG_SOURCE 列挙型の値で、WTSQueryUserConfig 関数が返す構成情報の取得元を指定します。
InheritInitialProgramDWORD4+4+4

クライアントが初期プログラムを指定できるかどうかを示す値です。このメンバーには次のいずれかの値を指定できます。

0

クライアントは初期プログラムを指定できません。代わりに、InitialProgram メンバーで指定されたプログラムが、ユーザーがサーバーにログオンしたときに自動的に開始されます。ユーザーがそのプログラムを終了すると、サーバーはそのユーザーをログオフします。

1

クライアントは初期プログラムを指定できます。

AllowLogonTerminalServerDWORD4+8+8

ユーザーアカウントが RD セッションホストサーバーへのログオンを許可されているかどうかを示す値です。このメンバーには次のいずれかの値を指定できます。

0

ユーザーはログオンできません。

1

ユーザーはログオンできます。

TimeoutSettingsConnectionsDWORD4+12+12接続の最大継続時間 (ミリ秒単位) です。接続が期限切れになる 1 分前に、サーバーは切断が保留されていることをユーザーに通知します。接続がタイムアウトすると、サーバーは BrokenTimeoutSettings メンバーで指定されたアクションを実行します。ユーザーがログオンするたびにタイマーはリセットされます。値が 0 の場合、接続タイマーは無効です。
TimeoutSettingsDisconnectionsDWORD4+16+16ログオンが終了されるまでに、切断されたセッションをサーバーが保持する最大時間 (ミリ秒単位) です。値が 0 の場合、切断タイマーは無効です。
TimeoutSettingsIdleDWORD4+20+20接続がアイドル状態のままでいられる時間 (ミリ秒単位) です。この時間だけキーボードまたはマウスの操作がない場合、サーバーは BrokenTimeoutSettings メンバーで指定されたアクションを実行します。値が 0 の場合、アイドルタイマーは無効です。
DeviceClientDrivesDWORD4+24+24このメンバーは予約済みです。
DeviceClientPrintersDWORD4+28+28

ユーザーがサーバーにログオンしたときに、以前にマップされたクライアントプリンターへサーバーが自動的に接続するかどうかを示す値です。このメンバーには次のいずれかの値を指定できます。

0

サーバーは、以前にマップされたクライアントプリンターへ自動的に接続しません。

1

サーバーは、以前にマップされたクライアントプリンターへ自動的に接続します。

ClientDefaultPrinterDWORD4+32+32

クライアントプリンターが既定のプリンターであるかどうかを示す値です。このメンバーには次のいずれかの値を指定できます。

0

クライアントプリンターは既定のプリンターではありません。

1

クライアントプリンターは既定のプリンターです。

BrokenTimeoutSettingsDWORD4+36+36

接続タイマーまたはアイドルタイマーが満了したとき、あるいは接続エラーによって接続が失われたときに、サーバーが実行するアクションです。このメンバーには次のいずれかの値を指定できます。

0

セッションは切断されますが、サーバー上には残ります。

1

セッションは終了されます。

ReconnectSettingsDWORD4+40+40

このユーザーの切断されたセッションをどのように再接続できるかを示す値です。このメンバーには次のいずれかの値を指定できます。

0

ユーザーは任意のクライアントコンピューターにログオンして、切断されたセッションに再接続できます。

1

ユーザーは、切断されたセッションを最初に確立したクライアントコンピューターにログオンする必要があります。別のクライアントコンピューターにログオンした場合は、新しいセッションが与えられます。

ShadowingSettingsDWORD4+44+44

リモートコントロールの設定です。リモートコントロールを使用すると、あるユーザーが別のユーザーの画面上の操作をリモートで監視できます。このメンバーには次のいずれかの値を指定できます。

0

リモートコントロールは無効です。

1

リモートコントロールを行うユーザーは、対象ユーザーの許可を得たうえで、そのユーザーのセッションを完全に制御できます。

2

リモートコントロールを行うユーザーは、対象ユーザーのセッションを完全に制御できます。対象ユーザーの許可は 必要ありません。

3

リモートコントロールを行うユーザーは、対象ユーザーの許可を得たうえでセッションをリモートで表示できます。リモート側のユーザーは セッションを能動的に制御することはできません。

4

リモートコントロールを行うユーザーは、セッションをリモートで表示できますが、能動的に制御することはできません。 対象ユーザーの許可は必要ありません。

TerminalServerRemoteHomeDirDWORD4+48+48

TerminalServerHomeDir メンバーに、ローカルディレクトリのパスとネットワーク共有のどちらが格納されているかを示す値です。このメンバーを WTSSetUserConfig 関数で設定することはできません。このメンバーには次のいずれかの値を指定できます。

0

TerminalServerHomeDir メンバーにはローカルディレクトリのパスが格納されています。

1

TerminalServerHomeDir メンバーにはネットワーク共有のパスが格納されており、TerminalServerHomeDirDrive メンバーには、そのパスがマップされているドライブ文字が格納されています。

InitialProgramCHAR261+52+52ユーザーがサーバーにログオンした直後に開始するプログラムの名前を格納する、null で終わる文字列です。
WorkDirectoryCHAR261+313+313初期プログラムの作業ディレクトリのパスを格納する、null で終わる文字列です。
TerminalServerProfilePathCHAR261+574+574ユーザーがサーバーに接続したときに、そのユーザーへ割り当てられるプロファイルパスを格納する、null で終わる文字列です。このパスで指定されるディレクトリは手動で作成する必要があり、ログオンより前に存在していなければなりません。
TerminalServerHomeDirCHAR261+835+835ユーザーのリモートデスクトップサービスセッションのホームフォルダーへのパスを格納する、null で終わる文字列です。このフォルダーはローカルフォルダーでもネットワーク共有でもかまいません。
TerminalServerHomeDirDriveCHAR4+1096+1096TerminalServerHomeDir メンバーで指定されたパスがマップされているドライブ名 (ドライブ文字とそれに続くコロン) を格納する、null で終わる文字列です。このメンバーは、TerminalServerRemoteHomeDir メンバーが 1 に設定されている場合にのみ有効です。

公式ドキュメント

ドメインコントローラーまたはリモートデスクトップセッションホスト (RD セッションホスト) サーバー上のユーザーの構成情報を格納します。この構造体は WTSQueryUserConfig 関数および WTSSetUserConfig 関数で使用されます。

解説(Remarks)

メモ

wtsapi32.h ヘッダーは、UNICODE プリプロセッサ定数の定義に基づいてこの関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして WTSUSERCONFIG を定義しています。エンコーディング中立のエイリアスの使用と、エンコーディング中立でないコードを混在させると、不一致が生じてコンパイルエラーや実行時エラーを引き起こすことがあります。詳細については、関数プロトタイプの規則 を参照してください。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での定義

#include <windows.h>

// WTSUSERCONFIGA  (x64 1100 / x86 1100 バイト)
typedef struct WTSUSERCONFIGA {
    DWORD Source;
    DWORD InheritInitialProgram;
    DWORD AllowLogonTerminalServer;
    DWORD TimeoutSettingsConnections;
    DWORD TimeoutSettingsDisconnections;
    DWORD TimeoutSettingsIdle;
    DWORD DeviceClientDrives;
    DWORD DeviceClientPrinters;
    DWORD ClientDefaultPrinter;
    DWORD BrokenTimeoutSettings;
    DWORD ReconnectSettings;
    DWORD ShadowingSettings;
    DWORD TerminalServerRemoteHomeDir;
    CHAR InitialProgram[261];
    CHAR WorkDirectory[261];
    CHAR TerminalServerProfilePath[261];
    CHAR TerminalServerHomeDir[261];
    CHAR TerminalServerHomeDirDrive[4];
} WTSUSERCONFIGA;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WTSUSERCONFIGA
{
    public uint Source;
    public uint InheritInitialProgram;
    public uint AllowLogonTerminalServer;
    public uint TimeoutSettingsConnections;
    public uint TimeoutSettingsDisconnections;
    public uint TimeoutSettingsIdle;
    public uint DeviceClientDrives;
    public uint DeviceClientPrinters;
    public uint ClientDefaultPrinter;
    public uint BrokenTimeoutSettings;
    public uint ReconnectSettings;
    public uint ShadowingSettings;
    public uint TerminalServerRemoteHomeDir;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 261)] public sbyte[] InitialProgram;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 261)] public sbyte[] WorkDirectory;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 261)] public sbyte[] TerminalServerProfilePath;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 261)] public sbyte[] TerminalServerHomeDir;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public sbyte[] TerminalServerHomeDirDrive;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WTSUSERCONFIGA
    Public Source As UInteger
    Public InheritInitialProgram As UInteger
    Public AllowLogonTerminalServer As UInteger
    Public TimeoutSettingsConnections As UInteger
    Public TimeoutSettingsDisconnections As UInteger
    Public TimeoutSettingsIdle As UInteger
    Public DeviceClientDrives As UInteger
    Public DeviceClientPrinters As UInteger
    Public ClientDefaultPrinter As UInteger
    Public BrokenTimeoutSettings As UInteger
    Public ReconnectSettings As UInteger
    Public ShadowingSettings As UInteger
    Public TerminalServerRemoteHomeDir As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=261)> Public InitialProgram() As SByte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=261)> Public WorkDirectory() As SByte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=261)> Public TerminalServerProfilePath() As SByte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=261)> Public TerminalServerHomeDir() As SByte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=4)> Public TerminalServerHomeDirDrive() As SByte
End Structure
import ctypes
from ctypes import wintypes

class WTSUSERCONFIGA(ctypes.Structure):
    _fields_ = [
        ("Source", wintypes.DWORD),
        ("InheritInitialProgram", wintypes.DWORD),
        ("AllowLogonTerminalServer", wintypes.DWORD),
        ("TimeoutSettingsConnections", wintypes.DWORD),
        ("TimeoutSettingsDisconnections", wintypes.DWORD),
        ("TimeoutSettingsIdle", wintypes.DWORD),
        ("DeviceClientDrives", wintypes.DWORD),
        ("DeviceClientPrinters", wintypes.DWORD),
        ("ClientDefaultPrinter", wintypes.DWORD),
        ("BrokenTimeoutSettings", wintypes.DWORD),
        ("ReconnectSettings", wintypes.DWORD),
        ("ShadowingSettings", wintypes.DWORD),
        ("TerminalServerRemoteHomeDir", wintypes.DWORD),
        ("InitialProgram", ctypes.c_byte * 261),
        ("WorkDirectory", ctypes.c_byte * 261),
        ("TerminalServerProfilePath", ctypes.c_byte * 261),
        ("TerminalServerHomeDir", ctypes.c_byte * 261),
        ("TerminalServerHomeDirDrive", ctypes.c_byte * 4),
    ]
#[repr(C)]
pub struct WTSUSERCONFIGA {
    pub Source: u32,
    pub InheritInitialProgram: u32,
    pub AllowLogonTerminalServer: u32,
    pub TimeoutSettingsConnections: u32,
    pub TimeoutSettingsDisconnections: u32,
    pub TimeoutSettingsIdle: u32,
    pub DeviceClientDrives: u32,
    pub DeviceClientPrinters: u32,
    pub ClientDefaultPrinter: u32,
    pub BrokenTimeoutSettings: u32,
    pub ReconnectSettings: u32,
    pub ShadowingSettings: u32,
    pub TerminalServerRemoteHomeDir: u32,
    pub InitialProgram: [i8; 261],
    pub WorkDirectory: [i8; 261],
    pub TerminalServerProfilePath: [i8; 261],
    pub TerminalServerHomeDir: [i8; 261],
    pub TerminalServerHomeDirDrive: [i8; 4],
}
import "golang.org/x/sys/windows"

type WTSUSERCONFIGA struct {
	Source uint32
	InheritInitialProgram uint32
	AllowLogonTerminalServer uint32
	TimeoutSettingsConnections uint32
	TimeoutSettingsDisconnections uint32
	TimeoutSettingsIdle uint32
	DeviceClientDrives uint32
	DeviceClientPrinters uint32
	ClientDefaultPrinter uint32
	BrokenTimeoutSettings uint32
	ReconnectSettings uint32
	ShadowingSettings uint32
	TerminalServerRemoteHomeDir uint32
	InitialProgram [261]int8
	WorkDirectory [261]int8
	TerminalServerProfilePath [261]int8
	TerminalServerHomeDir [261]int8
	TerminalServerHomeDirDrive [4]int8
}
type
  WTSUSERCONFIGA = record
    Source: DWORD;
    InheritInitialProgram: DWORD;
    AllowLogonTerminalServer: DWORD;
    TimeoutSettingsConnections: DWORD;
    TimeoutSettingsDisconnections: DWORD;
    TimeoutSettingsIdle: DWORD;
    DeviceClientDrives: DWORD;
    DeviceClientPrinters: DWORD;
    ClientDefaultPrinter: DWORD;
    BrokenTimeoutSettings: DWORD;
    ReconnectSettings: DWORD;
    ShadowingSettings: DWORD;
    TerminalServerRemoteHomeDir: DWORD;
    InitialProgram: array[0..260] of Shortint;
    WorkDirectory: array[0..260] of Shortint;
    TerminalServerProfilePath: array[0..260] of Shortint;
    TerminalServerHomeDir: array[0..260] of Shortint;
    TerminalServerHomeDirDrive: array[0..3] of Shortint;
  end;
const WTSUSERCONFIGA = extern struct {
    Source: u32,
    InheritInitialProgram: u32,
    AllowLogonTerminalServer: u32,
    TimeoutSettingsConnections: u32,
    TimeoutSettingsDisconnections: u32,
    TimeoutSettingsIdle: u32,
    DeviceClientDrives: u32,
    DeviceClientPrinters: u32,
    ClientDefaultPrinter: u32,
    BrokenTimeoutSettings: u32,
    ReconnectSettings: u32,
    ShadowingSettings: u32,
    TerminalServerRemoteHomeDir: u32,
    InitialProgram: [261]i8,
    WorkDirectory: [261]i8,
    TerminalServerProfilePath: [261]i8,
    TerminalServerHomeDir: [261]i8,
    TerminalServerHomeDirDrive: [4]i8,
};
type
  WTSUSERCONFIGA {.bycopy.} = object
    Source: uint32
    InheritInitialProgram: uint32
    AllowLogonTerminalServer: uint32
    TimeoutSettingsConnections: uint32
    TimeoutSettingsDisconnections: uint32
    TimeoutSettingsIdle: uint32
    DeviceClientDrives: uint32
    DeviceClientPrinters: uint32
    ClientDefaultPrinter: uint32
    BrokenTimeoutSettings: uint32
    ReconnectSettings: uint32
    ShadowingSettings: uint32
    TerminalServerRemoteHomeDir: uint32
    InitialProgram: array[261, int8]
    WorkDirectory: array[261, int8]
    TerminalServerProfilePath: array[261, int8]
    TerminalServerHomeDir: array[261, int8]
    TerminalServerHomeDirDrive: array[4, int8]
struct WTSUSERCONFIGA
{
    uint Source;
    uint InheritInitialProgram;
    uint AllowLogonTerminalServer;
    uint TimeoutSettingsConnections;
    uint TimeoutSettingsDisconnections;
    uint TimeoutSettingsIdle;
    uint DeviceClientDrives;
    uint DeviceClientPrinters;
    uint ClientDefaultPrinter;
    uint BrokenTimeoutSettings;
    uint ReconnectSettings;
    uint ShadowingSettings;
    uint TerminalServerRemoteHomeDir;
    byte[261] InitialProgram;
    byte[261] WorkDirectory;
    byte[261] TerminalServerProfilePath;
    byte[261] TerminalServerHomeDir;
    byte[4] TerminalServerHomeDirDrive;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; WTSUSERCONFIGA サイズ: 1100 バイト(x64)
dim st, 275    ; 4byte整数×275(構造体サイズ 1100 / 4 切り上げ)
; Source : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; InheritInitialProgram : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; AllowLogonTerminalServer : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; TimeoutSettingsConnections : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; TimeoutSettingsDisconnections : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; TimeoutSettingsIdle : DWORD (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; DeviceClientDrives : DWORD (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; DeviceClientPrinters : DWORD (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; ClientDefaultPrinter : DWORD (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; BrokenTimeoutSettings : DWORD (+36, 4byte)  st.9 = 値  /  値 = st.9   (lpoke/lpeek も可)
; ReconnectSettings : DWORD (+40, 4byte)  st.10 = 値  /  値 = st.10   (lpoke/lpeek も可)
; ShadowingSettings : DWORD (+44, 4byte)  st.11 = 値  /  値 = st.11   (lpoke/lpeek も可)
; TerminalServerRemoteHomeDir : DWORD (+48, 4byte)  st.12 = 値  /  値 = st.12   (lpoke/lpeek も可)
; InitialProgram : CHAR (+52, 261byte)  varptr(st)+52 を基点に操作(261byte:入れ子/配列)
; WorkDirectory : CHAR (+313, 261byte)  varptr(st)+313 を基点に操作(261byte:入れ子/配列)
; TerminalServerProfilePath : CHAR (+574, 261byte)  varptr(st)+574 を基点に操作(261byte:入れ子/配列)
; TerminalServerHomeDir : CHAR (+835, 261byte)  varptr(st)+835 を基点に操作(261byte:入れ子/配列)
; TerminalServerHomeDirDrive : CHAR (+1096, 4byte)  varptr(st)+1096 を基点に操作(4byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global WTSUSERCONFIGA
    #field int Source
    #field int InheritInitialProgram
    #field int AllowLogonTerminalServer
    #field int TimeoutSettingsConnections
    #field int TimeoutSettingsDisconnections
    #field int TimeoutSettingsIdle
    #field int DeviceClientDrives
    #field int DeviceClientPrinters
    #field int ClientDefaultPrinter
    #field int BrokenTimeoutSettings
    #field int ReconnectSettings
    #field int ShadowingSettings
    #field int TerminalServerRemoteHomeDir
    #field byte InitialProgram 261
    #field byte WorkDirectory 261
    #field byte TerminalServerProfilePath 261
    #field byte TerminalServerHomeDir 261
    #field byte TerminalServerHomeDirDrive 4
#endstruct

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