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

WTS_USER_DATA

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

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

フィールド

フィールドサイズx64x86説明
WorkDirectoryWCHAR514+0+0ユーザーの作業ディレクトリ。WCHARの固定長バッファ。
InitialProgramWCHAR514+514+514ユーザーの初期実行プログラムのパス。WCHARバッファ。
UserTimeZoneWTS_TIME_ZONE_INFORMATION172+1028+1028ユーザーのタイムゾーン情報。WTS_TIME_ZONE_INFORMATIONで表す。

各言語での定義

#include <windows.h>

// WTS_SYSTEMTIME  (x64 16 / x86 16 バイト)
typedef struct WTS_SYSTEMTIME {
    WORD wYear;
    WORD wMonth;
    WORD wDayOfWeek;
    WORD wDay;
    WORD wHour;
    WORD wMinute;
    WORD wSecond;
    WORD wMilliseconds;
} WTS_SYSTEMTIME;

// WTS_TIME_ZONE_INFORMATION  (x64 172 / x86 172 バイト)
typedef struct WTS_TIME_ZONE_INFORMATION {
    INT Bias;
    WCHAR StandardName[32];
    WTS_SYSTEMTIME StandardDate;
    INT StandardBias;
    WCHAR DaylightName[32];
    WTS_SYSTEMTIME DaylightDate;
    INT DaylightBias;
} WTS_TIME_ZONE_INFORMATION;

// WTS_USER_DATA  (x64 1200 / x86 1200 バイト)
typedef struct WTS_USER_DATA {
    WCHAR WorkDirectory[257];
    WCHAR InitialProgram[257];
    WTS_TIME_ZONE_INFORMATION UserTimeZone;
} WTS_USER_DATA;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WTS_SYSTEMTIME
{
    public ushort wYear;
    public ushort wMonth;
    public ushort wDayOfWeek;
    public ushort wDay;
    public ushort wHour;
    public ushort wMinute;
    public ushort wSecond;
    public ushort wMilliseconds;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WTS_TIME_ZONE_INFORMATION
{
    public int Bias;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] public string StandardName;
    public WTS_SYSTEMTIME StandardDate;
    public int StandardBias;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] public string DaylightName;
    public WTS_SYSTEMTIME DaylightDate;
    public int DaylightBias;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WTS_USER_DATA
{
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 257)] public string WorkDirectory;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 257)] public string InitialProgram;
    public WTS_TIME_ZONE_INFORMATION UserTimeZone;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WTS_SYSTEMTIME
    Public wYear As UShort
    Public wMonth As UShort
    Public wDayOfWeek As UShort
    Public wDay As UShort
    Public wHour As UShort
    Public wMinute As UShort
    Public wSecond As UShort
    Public wMilliseconds As UShort
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WTS_TIME_ZONE_INFORMATION
    Public Bias As Integer
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=32)> Public StandardName As String
    Public StandardDate As WTS_SYSTEMTIME
    Public StandardBias As Integer
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=32)> Public DaylightName As String
    Public DaylightDate As WTS_SYSTEMTIME
    Public DaylightBias As Integer
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WTS_USER_DATA
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=257)> Public WorkDirectory As String
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=257)> Public InitialProgram As String
    Public UserTimeZone As WTS_TIME_ZONE_INFORMATION
End Structure
import ctypes
from ctypes import wintypes

class WTS_SYSTEMTIME(ctypes.Structure):
    _fields_ = [
        ("wYear", ctypes.c_ushort),
        ("wMonth", ctypes.c_ushort),
        ("wDayOfWeek", ctypes.c_ushort),
        ("wDay", ctypes.c_ushort),
        ("wHour", ctypes.c_ushort),
        ("wMinute", ctypes.c_ushort),
        ("wSecond", ctypes.c_ushort),
        ("wMilliseconds", ctypes.c_ushort),
    ]

class WTS_TIME_ZONE_INFORMATION(ctypes.Structure):
    _fields_ = [
        ("Bias", ctypes.c_int),
        ("StandardName", ctypes.c_wchar * 32),
        ("StandardDate", WTS_SYSTEMTIME),
        ("StandardBias", ctypes.c_int),
        ("DaylightName", ctypes.c_wchar * 32),
        ("DaylightDate", WTS_SYSTEMTIME),
        ("DaylightBias", ctypes.c_int),
    ]

class WTS_USER_DATA(ctypes.Structure):
    _fields_ = [
        ("WorkDirectory", ctypes.c_wchar * 257),
        ("InitialProgram", ctypes.c_wchar * 257),
        ("UserTimeZone", WTS_TIME_ZONE_INFORMATION),
    ]
#[repr(C)]
pub struct WTS_SYSTEMTIME {
    pub wYear: u16,
    pub wMonth: u16,
    pub wDayOfWeek: u16,
    pub wDay: u16,
    pub wHour: u16,
    pub wMinute: u16,
    pub wSecond: u16,
    pub wMilliseconds: u16,
}

#[repr(C)]
pub struct WTS_TIME_ZONE_INFORMATION {
    pub Bias: i32,
    pub StandardName: [u16; 32],
    pub StandardDate: WTS_SYSTEMTIME,
    pub StandardBias: i32,
    pub DaylightName: [u16; 32],
    pub DaylightDate: WTS_SYSTEMTIME,
    pub DaylightBias: i32,
}

#[repr(C)]
pub struct WTS_USER_DATA {
    pub WorkDirectory: [u16; 257],
    pub InitialProgram: [u16; 257],
    pub UserTimeZone: WTS_TIME_ZONE_INFORMATION,
}
import "golang.org/x/sys/windows"

type WTS_SYSTEMTIME struct {
	wYear uint16
	wMonth uint16
	wDayOfWeek uint16
	wDay uint16
	wHour uint16
	wMinute uint16
	wSecond uint16
	wMilliseconds uint16
}

type WTS_TIME_ZONE_INFORMATION struct {
	Bias int32
	StandardName [32]uint16
	StandardDate WTS_SYSTEMTIME
	StandardBias int32
	DaylightName [32]uint16
	DaylightDate WTS_SYSTEMTIME
	DaylightBias int32
}

type WTS_USER_DATA struct {
	WorkDirectory [257]uint16
	InitialProgram [257]uint16
	UserTimeZone WTS_TIME_ZONE_INFORMATION
}
type
  WTS_SYSTEMTIME = record
    wYear: Word;
    wMonth: Word;
    wDayOfWeek: Word;
    wDay: Word;
    wHour: Word;
    wMinute: Word;
    wSecond: Word;
    wMilliseconds: Word;
  end;

  WTS_TIME_ZONE_INFORMATION = record
    Bias: Integer;
    StandardName: array[0..31] of WideChar;
    StandardDate: WTS_SYSTEMTIME;
    StandardBias: Integer;
    DaylightName: array[0..31] of WideChar;
    DaylightDate: WTS_SYSTEMTIME;
    DaylightBias: Integer;
  end;

  WTS_USER_DATA = record
    WorkDirectory: array[0..256] of WideChar;
    InitialProgram: array[0..256] of WideChar;
    UserTimeZone: WTS_TIME_ZONE_INFORMATION;
  end;
const WTS_SYSTEMTIME = extern struct {
    wYear: u16,
    wMonth: u16,
    wDayOfWeek: u16,
    wDay: u16,
    wHour: u16,
    wMinute: u16,
    wSecond: u16,
    wMilliseconds: u16,
};

const WTS_TIME_ZONE_INFORMATION = extern struct {
    Bias: i32,
    StandardName: [32]u16,
    StandardDate: WTS_SYSTEMTIME,
    StandardBias: i32,
    DaylightName: [32]u16,
    DaylightDate: WTS_SYSTEMTIME,
    DaylightBias: i32,
};

const WTS_USER_DATA = extern struct {
    WorkDirectory: [257]u16,
    InitialProgram: [257]u16,
    UserTimeZone: WTS_TIME_ZONE_INFORMATION,
};
type
  WTS_SYSTEMTIME {.bycopy.} = object
    wYear: uint16
    wMonth: uint16
    wDayOfWeek: uint16
    wDay: uint16
    wHour: uint16
    wMinute: uint16
    wSecond: uint16
    wMilliseconds: uint16

  WTS_TIME_ZONE_INFORMATION {.bycopy.} = object
    Bias: int32
    StandardName: array[32, uint16]
    StandardDate: WTS_SYSTEMTIME
    StandardBias: int32
    DaylightName: array[32, uint16]
    DaylightDate: WTS_SYSTEMTIME
    DaylightBias: int32

  WTS_USER_DATA {.bycopy.} = object
    WorkDirectory: array[257, uint16]
    InitialProgram: array[257, uint16]
    UserTimeZone: WTS_TIME_ZONE_INFORMATION
struct WTS_SYSTEMTIME
{
    ushort wYear;
    ushort wMonth;
    ushort wDayOfWeek;
    ushort wDay;
    ushort wHour;
    ushort wMinute;
    ushort wSecond;
    ushort wMilliseconds;
}

struct WTS_TIME_ZONE_INFORMATION
{
    int Bias;
    wchar[32] StandardName;
    WTS_SYSTEMTIME StandardDate;
    int StandardBias;
    wchar[32] DaylightName;
    WTS_SYSTEMTIME DaylightDate;
    int DaylightBias;
}

struct WTS_USER_DATA
{
    wchar[257] WorkDirectory;
    wchar[257] InitialProgram;
    WTS_TIME_ZONE_INFORMATION UserTimeZone;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; WTS_USER_DATA サイズ: 1200 バイト(x64)
dim st, 300    ; 4byte整数×300(構造体サイズ 1200 / 4 切り上げ)
; WorkDirectory : WCHAR (+0, 514byte)  varptr(st)+0 を基点に操作(514byte:入れ子/配列)
; InitialProgram : WCHAR (+514, 514byte)  varptr(st)+514 を基点に操作(514byte:入れ子/配列)
; UserTimeZone : WTS_TIME_ZONE_INFORMATION (+1028, 172byte)  varptr(st)+1028 を基点に操作(172byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global WTS_SYSTEMTIME
    #field short wYear
    #field short wMonth
    #field short wDayOfWeek
    #field short wDay
    #field short wHour
    #field short wMinute
    #field short wSecond
    #field short wMilliseconds
#endstruct

#defstruct global WTS_TIME_ZONE_INFORMATION
    #field int Bias
    #field wchar StandardName 32
    #field WTS_SYSTEMTIME StandardDate
    #field int StandardBias
    #field wchar DaylightName 32
    #field WTS_SYSTEMTIME DaylightDate
    #field int DaylightBias
#endstruct

#defstruct global WTS_USER_DATA
    #field wchar WorkDirectory 257
    #field wchar InitialProgram 257
    #field WTS_TIME_ZONE_INFORMATION UserTimeZone
#endstruct

stdim st, WTS_USER_DATA        ; NSTRUCT 変数を確保