WTSINFO structure

Expand
0 out of 1 rated this helpful - Rate this topic

WTSINFO structure

Applies to: desktop apps only

Contains information about a Remote Desktop Services session.

Syntax

typedef struct _WTSINFO {
  WTS_CONNECTSTATE_CLASS State;
  DWORD                  SessionId;
  DWORD                  IncomingBytes;
  DWORD                  OutgoingBytes;
  DWORD                  IncomingCompressedBytes;
  DWORD                  OutgoingCompressedBytes;
  WCHAR                  WinStationName;
  WCHAR                  Domain;
  WCHAR                  UserName;
  LARGE_INTEGER          ConnectTime;
  LARGE_INTEGER          DisconnectTime;
  LARGE_INTEGER          LastInputTime;
  LARGE_INTEGER          LogonTime;
  LARGE_INTEGER          CurrentTime;
} WTSINFO, *PWTSINFO;

Members

State

A value of the WTS_CONNECTSTATE_CLASS enumeration type that indicates the session's current connection state.

SessionId

The session identifier.

IncomingBytes

Uncompressed Remote Desktop Protocol (RDP) data from the client to the server.

OutgoingBytes

Uncompressed RDP data from the server to the client.

IncomingCompressedBytes

Compressed RDP data from the client to the server.

OutgoingCompressedBytes

Compressed RDP data from the server to the client.

WinStationName

A null-terminated string containing the name of the WinStation for the session.

Domain

The domain that the user belongs to.

UserName

Name of the user who owns the session.

ConnectTime

The most recent client connection time.

DisconnectTime

The last client disconnection time.

LastInputTime

The time of the last user input in the session.

LogonTime

The time that the user logged on to the session.

CurrentTime

The time that the WTSINFO data structure was called.

Requirements

Minimum supported client

Windows Vista with SP1

Minimum supported server

Windows Server 2008

Header

Wtsapi32.h

Unicode and ANSI names

WTSINFOW (Unicode) and WTSINFOA (ANSI)

 

 

Send comments about this topic to Microsoft

Build date: 5/5/2012

Did you find this helpful?
(1500 characters remaining)
Community Additions ADD
Converting LARGE_INTEGERs to .NET DateTimes
It looks like we're supposed to use DateTime.FromFileTime and DateTime.FromFileTimeUtc to convert the five time parameters to DateTime structures.
8/18/2008
WTSINFO Structure Definition with .NET Interop Definition.

The actual (UNICODE) structure definition is as follows:

typedef struct _WTSINFOW {
WTS_CONNECTSTATE_CLASS State; // connection state (see enum)
DWORD SessionId; // session id
DWORD IncomingBytes;
DWORD OutgoingBytes;
DWORD IncomingFrames;
DWORD OutgoingFrames;
DWORD IncomingCompressedBytes;
DWORD OutgoingCompressedBytes;
WCHAR WinStationName[WINSTATIONNAME_LENGTH];
WCHAR Domain[DOMAIN_LENGTH];
WCHAR UserName[USERNAME_LENGTH+1];// name of WinStation this session is connected to
LARGE_INTEGER ConnectTime;
LARGE_INTEGER DisconnectTime;
LARGE_INTEGER LastInputTime;
LARGE_INTEGER LogonTime;
LARGE_INTEGER CurrentTime;


} WTSINFOW, * PWTSINFOW;

Please note that several of the structure members are returned zeroed out on Vista SP1. This includes the Incoming/Outgoing Bytes (and CompressedBytes), Incoming/Outgoing Frames, and the LastInputTime. I do not know if Windows Server 2008 zeroes these members as well.

Below is the .NET interop definition of this structure.

public const int WINSTATIONNAME_LENGTH = 32;
public const int DOMAIN_LENGTH = 17;
public const int USERNAME_LENGTH = 20;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WTSINFO
{
public WTS_CONNECTSTATE_CLASS State;
public UInt32 SessionId;
public UInt32 IncomingBytes;
public UInt32 OutgoingBytes;
public UInt32 IncomingFrames;
public UInt32 OutgoingFrames;
public UInt32 IncomingCompressedBytes;
public UInt32 OutgoingCompressedBytes;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = WINSTATIONNAME_LENGTH)]
public String WinStationName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = DOMAIN_LENGTH)]
public String Domain;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = USERNAME_LENGTH + 1)]
public String UserName;
[MarshalAs(UnmanagedType.I8)]
public Int64 ConnectTime;
[MarshalAs(UnmanagedType.I8)]
public Int64 DisconnectTime;
[MarshalAs(UnmanagedType.I8)]
public Int64 LastInputTime;
[MarshalAs(UnmanagedType.I8)]
public Int64 LogonTime;
[MarshalAs(UnmanagedType.I8)]
public Int64 CurrentTime;
}

3/19/2008