[cassia] r120 committed - Issue 49: Applied patch from Thilo Langbein adding a new SessionIPAddr...

16 views
Skip to first unread message

cas...@googlecode.com

unread,
Aug 20, 2014, 9:18:08 AM8/20/14
to cassi...@googlegroups.com
Revision: 120
Author: danp...@gmail.com
Date: Wed Aug 20 13:17:52 2014 UTC
Log: Issue 49: Applied patch from Thilo Langbein adding a new
SessionIPAddress property to ITerminalServicesSession.
http://code.google.com/p/cassia/source/detail?r=120

Added:
/trunk/Source/Cassia/Impl/WTS_SESSION_ADDRESS.cs
Modified:
/trunk/Source/Cassia
/trunk/Source/Cassia/Cassia.csproj
/trunk/Source/Cassia/ITerminalServicesSession.cs
/trunk/Source/Cassia/Impl/TerminalServicesSession.cs

=======================================
--- /dev/null
+++ /trunk/Source/Cassia/Impl/WTS_SESSION_ADDRESS.cs Wed Aug 20 13:17:52
2014 UTC
@@ -0,0 +1,14 @@
+using System.Net.Sockets;
+using System.Runtime.InteropServices;
+
+namespace Cassia.Impl
+{
+ [StructLayout(LayoutKind.Sequential)]
+ public struct WTS_SESSION_ADDRESS
+ {
+ public AddressFamily AddressFamily;
+
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
+ public byte[] Address;
+ }
+}
=======================================
--- /trunk/Source/Cassia/Cassia.csproj Tue Dec 21 02:08:48 2010 UTC
+++ /trunk/Source/Cassia/Cassia.csproj Wed Aug 20 13:17:52 2014 UTC
@@ -51,6 +51,7 @@
<Compile Include="Impl\ClientDisplay.cs" />
<Compile Include="IClientDisplay.cs" />
<Compile Include="Impl\GroupLazyLoadedProperty.cs" />
+ <Compile Include="Impl\WTS_SESSION_ADDRESS.cs" />
<Compile Include="IProtocolStatistics.cs" />
<Compile Include="Impl\NamespaceDoc.cs" />
<Compile Include="ConnectionState.cs" />
=======================================
--- /trunk/Source/Cassia/ITerminalServicesSession.cs Sun Apr 4 03:25:02
2010 UTC
+++ /trunk/Source/Cassia/ITerminalServicesSession.cs Wed Aug 20 13:17:52
2014 UTC
@@ -6,274 +6,299 @@
namespace Cassia
{
/// <summary>
- /// A session on a terminal server.
+ /// A session on a terminal server.
/// </summary>
/// <remarks>
- /// Note that many of the properties exposed by this interface may
only be loaded on demand,
- /// so ensure that a connection to the terminal server is open
- /// (by calling <see cref="ITerminalServer.Open()" />) before
accessing properties or performing
- /// operations on a session.
+ /// Note that many of the properties exposed by this interface may
only be loaded on demand,
+ /// so ensure that a connection to the terminal server is open
+ /// (by calling <see cref="ITerminalServer.Open()" />) before
accessing properties or performing
+ /// operations on a session.
/// </remarks>
public interface ITerminalServicesSession
{
/// <summary>
- /// The name of the machine last connected to this session.
+ /// The name of the machine last connected to this session.
/// </summary>
string ClientName { get; }

/// <summary>
- /// The connection state of the session.
+ /// The connection state of the session.
/// </summary>
ConnectionState ConnectionState { get; }

/// <summary>
- /// The time at which the user connected to this session.
+ /// The time at which the user connected to this session.
/// </summary>
/// <remarks>
- /// May be <c>null</c>, e.g. for a listening session.
+ /// May be <c>null</c>, e.g. for a listening session.
/// </remarks>
DateTime? ConnectTime { get; }

/// <summary>
- /// The current time in the session.
+ /// The current time in the session.
/// </summary>
/// <remarks>
- /// May be <c>null</c>, e.g. for a listening session.
+ /// May be <c>null</c>, e.g. for a listening session.
/// </remarks>
DateTime? CurrentTime { get; }

/// <summary>
- /// The time at which the user disconnected from this session.
+ /// The time at which the user disconnected from this session.
/// </summary>
/// <remarks>
- /// May be <c>null</c>, e.g. if the user has never disconnected
from the session.
+ /// May be <c>null</c>, e.g. if the user has never
disconnected from the session.
/// </remarks>
DateTime? DisconnectTime { get; }

/// <summary>
- /// The time at which this session last received input -- mouse
movements, key presses, etc.
+ /// The time at which this session last received input --
mouse movements, key presses, etc.
/// </summary>
/// <remarks>
- /// May be <c>null</c>, e.g. for a listening session that receives
no user input.
+ /// May be <c>null</c>, e.g. for a listening session that
receives no user input.
/// </remarks>
DateTime? LastInputTime { get; }

/// <summary>
- /// The time at which the user logged into this session for the
first time.
+ /// The time at which the user logged into this session for
the first time.
/// </summary>
/// <remarks>
- /// May be <c>null</c>, e.g. for a listening session.
+ /// May be <c>null</c>, e.g. for a listening session.
/// </remarks>
DateTime? LoginTime { get; }

/// <summary>
- /// Length of time that the session has been idle.
+ /// Length of time that the session has been idle.
/// </summary>
/// <remarks>
- /// <para>For connected sessions, this will return the time since
the session
- /// last received user input.</para>
- /// <para>For disconnected sessions, this will return the length
of time that the user
- /// has been disconnected from the session.</para>
- /// <para>This will return <c>TimeSpan.Zero</c> if the idle time
could not be determined.</para>
+ /// <para>
+ /// For connected sessions, this will return the time
since the session
+ /// last received user input.
+ /// </para>
+ /// <para>
+ /// For disconnected sessions, this will return the length
of time that the user
+ /// has been disconnected from the session.
+ /// </para>
+ /// <para>This will return <c>TimeSpan.Zero</c> if the idle
time could not be determined.</para>
/// </remarks>
TimeSpan IdleTime { get; }

/// <summary>
- /// The ID of the session.
+ /// The ID of the session.
/// </summary>
int SessionId { get; }

/// <summary>
- /// The name of the user account that last connected to the
session.
+ /// The name of the user account that last connected to the
session.
/// </summary>
string UserName { get; }

/// <summary>
- /// The domain of the user account that last connected to the
session.
+ /// The domain of the user account that last connected to the
session.
/// </summary>
string DomainName { get; }

/// <summary>
- /// The user account that last connected to the session.
+ /// The user account that last connected to the session.
/// </summary>
NTAccount UserAccount { get; }

/// <summary>
- /// The name of the session's window station.
+ /// The name of the session's window station.
/// </summary>
string WindowStationName { get; }

/// <summary>
- /// The IP address reported by the client.
+ /// The IP address reported by the client.
/// </summary>
- /// <remarks>Note that this is not guaranteed to be the client's
actual, remote
- /// IP address -- if the client is behind a router with NAT, for
example, the IP address
- /// reported will be the client's internal IP address on its
LAN.</remarks>
+ /// <remarks>
+ /// Note that this is not guaranteed to be the client's
actual, remote
+ /// IP address -- if the client is behind a router with NAT,
for example, the IP address
+ /// reported will be the client's internal IP address on its
LAN.
+ /// </remarks>
IPAddress ClientIPAddress { get; }

/// <summary>
- /// The terminal server on which this session is located.
+ /// The virtual IP address assigned to this session.
+ /// </summary>
+ /// <remarks>
+ /// This is only supported on Windows Server 2008 R2/Windows 7
and later. It will throw an exception if the session
+ /// does not have a virtual IP address.
+ /// </remarks>
+ IPAddress SessionIPAddress { get; }
+
+ /// <summary>
+ /// The terminal server on which this session is located.
/// </summary>
ITerminalServer Server { get; }

/// <summary>
- /// The build number of the client.
+ /// The build number of the client.
/// </summary>
/// <remarks>
- /// <para>Note that this does not include the major version, minor
- /// version, or revision number -- it is only the build number.
For example, the full file version
- /// of the RDP 6 client on Windows XP is 6.0.6001.18000, so this
property will return 6001
- /// for this client.</para>
- /// <para>May be zero, e.g. for a listening session.</para>
+ /// <para>
+ /// Note that this does not include the major version,
minor
+ /// version, or revision number -- it is only the build
number. For example, the full file version
+ /// of the RDP 6 client on Windows XP is 6.0.6001.18000,
so this property will return 6001
+ /// for this client.
+ /// </para>
+ /// <para>May be zero, e.g. for a listening session.</para>
/// </remarks>
int ClientBuildNumber { get; }

/// <summary>
- /// Information about a client's display.
+ /// Information about a client's display.
/// </summary>
IClientDisplay ClientDisplay { get; }

/// <summary>
- /// Directory on the client computer in which the client software
is installed.
+ /// Directory on the client computer in which the client
software is installed.
/// </summary>
/// <remarks>
- /// This is typically the full path to the RDP ActiveX control DLL
on the client machine; e.g.
- /// <c>C:\WINDOWS\SYSTEM32\mstscax.dll</c>.
+ /// This is typically the full path to the RDP ActiveX control
DLL on the client machine; e.g.
+ /// <c>C:\WINDOWS\SYSTEM32\mstscax.dll</c>.
/// </remarks>
string ClientDirectory { get; }

/// <summary>
- /// Client-specific hardware identifier.
+ /// Client-specific hardware identifier.
/// </summary>
/// <remarks>
- /// This value is typically <c>0</c>.
+ /// This value is typically <c>0</c>.
/// </remarks>
int ClientHardwareId { get; }

/// <summary>
- /// Client-specific product identifier.
+ /// Client-specific product identifier.
/// </summary>
/// <remarks>
- /// This value is typically <c>1</c> for the standard RDP client.
+ /// This value is typically <c>1</c> for the standard RDP
client.
/// </remarks>
short ClientProductId { get; }

/// <summary>
- /// The protocol that the client is using to connect to the
session.
+ /// The protocol that the client is using to connect to the
session.
/// </summary>
ClientProtocolType ClientProtocolType { get; }

/// <summary>
- /// The working directory used when launching the initial program.
+ /// The working directory used when launching the initial
program.
/// </summary>
/// <remarks>
- /// This property may throw an exception for the console session
(where
- /// <see cref="ClientProtocolType"/> is <see
cref="Cassia.ClientProtocolType.Console" />).
+ /// This property may throw an exception for the console
session (where
+ /// <see cref="ClientProtocolType" /> is <see
cref="Cassia.ClientProtocolType.Console" />).
/// </remarks>
string WorkingDirectory { get; }

/// <summary>
- /// The initial program run when the session started.
+ /// The initial program run when the session started.
/// </summary>
/// <remarks>
- /// This property may throw an exception for the console session
(where
- /// <see cref="ClientProtocolType"/> is <see
cref="Cassia.ClientProtocolType.Console" />).
+ /// This property may throw an exception for the console
session (where
+ /// <see cref="ClientProtocolType" /> is <see
cref="Cassia.ClientProtocolType.Console" />).
/// </remarks>
string InitialProgram { get; }

/// <summary>
- /// The remote endpoint (IP address and port) of the client
connected to the session.
+ /// The remote endpoint (IP address and port) of the client
connected to the session.
/// </summary>
/// <remarks>
- /// This property currently supports only IPv4 addresses, and will
be <c>null</c> if
- /// no client is connected to the session.
+ /// This property currently supports only IPv4 addresses, and
will be <c>null</c> if
+ /// no client is connected to the session.
/// </remarks>
EndPoint RemoteEndPoint { get; }

/// <summary>
- /// Name of the published application that this session is running.
+ /// Name of the published application that this session is
running.
/// </summary>
/// <remarks>
- /// This property may throw an exception for the console session
(where
- /// <see cref="ClientProtocolType"/> is <see
cref="Cassia.ClientProtocolType.Console" />).
+ /// This property may throw an exception for the console
session (where
+ /// <see cref="ClientProtocolType" /> is <see
cref="Cassia.ClientProtocolType.Console" />).
/// </remarks>
string ApplicationName { get; }

/// <summary>
- /// Gets a value indicating whether this session is running on the
local terminal server.
+ /// Gets a value indicating whether this session is running on
the local terminal server.
/// </summary>
bool Local { get; }

/// <summary>
- /// Incoming protocol statistics for the session.
+ /// Incoming protocol statistics for the session.
/// </summary>
IProtocolStatistics IncomingStatistics { get; }

/// <summary>
- /// Outgoing protocol statistics for the session.
+ /// Outgoing protocol statistics for the session.
/// </summary>
IProtocolStatistics OutgoingStatistics { get; }

/// <overloads>
- /// <summary>
- /// Logs the session off, disconnecting any user that might be
attached.
- /// </summary>
+ /// <summary>
+ /// Logs the session off, disconnecting any user that
might be attached.
+ /// </summary>
/// </overloads>
/// <summary>
- /// Logs the session off, disconnecting any user that might be
attached.
+ /// Logs the session off, disconnecting any user that might be
attached.
/// </summary>
- /// <remarks>The logoff takes place synchronously; this method
returns after the operation is complete.
- /// This is the same as calling <c>Logoff(true)</c>.</remarks>
+ /// <remarks>
+ /// The logoff takes place synchronously; this method returns
after the operation is complete.
+ /// This is the same as calling <c>Logoff(true)</c>.
+ /// </remarks>
void Logoff();

/// <summary>
- /// Logs the session off, disconnecting any user that might be
attached.
+ /// Logs the session off, disconnecting any user that might be
attached.
/// </summary>
- /// <param name="synchronous">If <c>true</c>, waits until the
session is fully logged off
- /// before returning from the method. If <c>false</c>, returns
immediately, even though
- /// the session may not be completely logged off yet.</param>
+ /// <param name="synchronous">
+ /// If <c>true</c>, waits until the session is fully logged off
+ /// before returning from the method. If <c>false</c>, returns
immediately, even though
+ /// the session may not be completely logged off yet.
+ /// </param>
void Logoff(bool synchronous);

/// <overloads>
- /// <summary>
- /// Disconnects any attached user from the session.
- /// </summary>
+ /// <summary>
+ /// Disconnects any attached user from the session.
+ /// </summary>
/// </overloads>
/// <summary>
- /// Disconnects any attached user from the session.
+ /// Disconnects any attached user from the session.
/// </summary>
- /// <remarks>The disconnection takes place synchronously; this
method returns after the operation is complete.
- /// This is the same as calling <c>Disconnect(true)</c>.</remarks>
+ /// <remarks>
+ /// The disconnection takes place synchronously; this method
returns after the operation is complete.
+ /// This is the same as calling <c>Disconnect(true)</c>.
+ /// </remarks>
void Disconnect();

/// <summary>
- /// Disconnects any attached user from the session.
+ /// Disconnects any attached user from the session.
/// </summary>
- /// <param name="synchronous">If <c>true</c>, waits until the
session is fully disconnected
- /// before returning from the method. If <c>false</c>, returns
immediately, even though
- /// the session may not be completely disconnected yet.</param>
+ /// <param name="synchronous">
+ /// If <c>true</c>, waits until the session is fully
disconnected
+ /// before returning from the method. If <c>false</c>, returns
immediately, even though
+ /// the session may not be completely disconnected yet.
+ /// </param>
void Disconnect(bool synchronous);

/// <overloads>
- /// <summary>
- /// Displays a message box in the session.
- /// </summary>
+ /// <summary>
+ /// Displays a message box in the session.
+ /// </summary>
/// </overloads>
/// <summary>
- /// Displays a message box in the session.
+ /// Displays a message box in the session.
/// </summary>
/// <param name="text">The text to display in the message
box.</param>
void MessageBox(string text);

/// <summary>
- /// Displays a message box in the session.
+ /// Displays a message box in the session.
/// </summary>
/// <param name="text">The text to display in the message
box.</param>
/// <param name="caption">The caption of the message box.</param>
void MessageBox(string text, string caption);

/// <summary>
- /// Displays a message box in the session.
+ /// Displays a message box in the session.
/// </summary>
/// <param name="text">The text to display in the message
box.</param>
/// <param name="caption">The caption of the message box.</param>
@@ -281,7 +306,7 @@
void MessageBox(string text, string caption, RemoteMessageBoxIcon
icon);

/// <summary>
- /// Displays a message box in the session and returns the user's
response to the message box.
+ /// Displays a message box in the session and returns the
user's response to the message box.
/// </summary>
/// <param name="text">The text to display in the message
box.</param>
/// <param name="caption">The caption of the message box.</param>
@@ -289,60 +314,70 @@
/// <param name="icon">The icon to display in the message
box.</param>
/// <param name="defaultButton">The button that should be selected
by default in the message box.</param>
/// <param name="options">Options for the message box.</param>
- /// <param name="timeout">The amount of time to wait for a
response from the user
- /// before closing the message box. The system will wait forever
if this is set to <c>TimeSpan.Zero</c>.
- /// This will be treated as a integer number of seconds --
- /// specifying <c>TimeSpan.FromSeconds(2.5)</c> will produce the
same result as
- /// <c>TimeSpan.FromSeconds(2)</c>.</param>
- /// <param name="synchronous">If <c>true</c>, wait for and return
the user's response to the
- /// message box. Otherwise, return immediately.</param>
- /// <returns>The user's response to the message box. If <paramref
name="synchronous" />
- /// is <c>false</c>, the method will always return <see
cref="RemoteMessageBoxResult.Asynchronous" />.
- /// If the timeout expired before the user responded to the
message box, the result will be
- /// <see cref="RemoteMessageBoxResult.Timeout" />.</returns>
+ /// <param name="timeout">
+ /// The amount of time to wait for a response from the user
+ /// before closing the message box. The system will wait
forever if this is set to <c>TimeSpan.Zero</c>.
+ /// This will be treated as a integer number of seconds --
+ /// specifying <c>TimeSpan.FromSeconds(2.5)</c> will produce
the same result as
+ /// <c>TimeSpan.FromSeconds(2)</c>.
+ /// </param>
+ /// <param name="synchronous">
+ /// If <c>true</c>, wait for and return the user's response to
the
+ /// message box. Otherwise, return immediately.
+ /// </param>
+ /// <returns>
+ /// The user's response to the message box. If <paramref
name="synchronous" />
+ /// is <c>false</c>, the method will always return <see
cref="RemoteMessageBoxResult.Asynchronous" />.
+ /// If the timeout expired before the user responded to the
message box, the result will be
+ /// <see cref="RemoteMessageBoxResult.Timeout" />.
+ /// </returns>
RemoteMessageBoxResult MessageBox(string text, string caption,
RemoteMessageBoxButtons buttons,
- RemoteMessageBoxIcon icon,
RemoteMessageBoxDefaultButton defaultButton,
- RemoteMessageBoxOptions options,
TimeSpan timeout, bool synchronous);
+ RemoteMessageBoxIcon icon, RemoteMessageBoxDefaultButton
defaultButton, RemoteMessageBoxOptions options,
+ TimeSpan timeout, bool synchronous);

/// <summary>
- /// Retreives a list of processes running in this session.
+ /// Retreives a list of processes running in this session.
/// </summary>
/// <returns>A list of processes.</returns>
IList<ITerminalServicesProcess> GetProcesses();

/// <summary>
- /// Starts remote control of the session.
+ /// Starts remote control of the session.
/// </summary>
/// <param name="hotkey">The key to press to stop remote control
of the session.</param>
/// <param name="hotkeyModifiers">The modifiers for the key to
press to stop remote control.s</param>
/// <remarks>
- /// This method can only be called while running in a remote
session. It blocks until remote control
- /// has ended, which could result from pressing the hotkey,
logging off the target session,
- /// or disconnecting the target session (among other things).
+ /// This method can only be called while running in a remote
session. It blocks until remote control
+ /// has ended, which could result from pressing the hotkey,
logging off the target session,
+ /// or disconnecting the target session (among other things).
/// </remarks>
void StartRemoteControl(ConsoleKey hotkey,
RemoteControlHotkeyModifiers hotkeyModifiers);

/// <summary>
- /// Stops remote control of the session. The session must be
running on the local server.
+ /// Stops remote control of the session. The session must be
running on the local server.
/// </summary>
/// <remarks>
- /// This method should be called on the session that is being
shadowed, not on the session that
- /// is shadowing.
+ /// This method should be called on the session that is being
shadowed, not on the session that
+ /// is shadowing.
/// </remarks>
void StopRemoteControl();

/// <summary>
- /// Connects this session to an existing session. Both sessions
must be running on the local server.
+ /// Connects this session to an existing session. Both
sessions must be running on the local server.
/// </summary>
/// <param name="target">The session to which to connect.</param>
- /// <param name="password">The password of the user logged on to
the target session.
- /// If the user logged on to the target session is the same as the
user logged on to this session,
- /// this parameter can be an empty string.</param>
- /// <param name="synchronous">If <c>true</c>, waits until the
operation has completed
- /// before returning from the method. If <c>false</c>, returns
immediately, even though
- /// the operation may not be complete yet.</param>
+ /// <param name="password">
+ /// The password of the user logged on to the target session.
+ /// If the user logged on to the target session is the same as
the user logged on to this session,
+ /// this parameter can be an empty string.
+ /// </param>
+ /// <param name="synchronous">
+ /// If <c>true</c>, waits until the operation has completed
+ /// before returning from the method. If <c>false</c>, returns
immediately, even though
+ /// the operation may not be complete yet.
+ /// </param>
/// <remarks>
- /// The user logged on to this session must have permissions to
connect to the target session.
+ /// The user logged on to this session must have permissions
to connect to the target session.
/// </remarks>
void Connect(ITerminalServicesSession target, string password,
bool synchronous);
}
=======================================
--- /trunk/Source/Cassia/Impl/TerminalServicesSession.cs Tue Apr 26
22:44:05 2011 UTC
+++ /trunk/Source/Cassia/Impl/TerminalServicesSession.cs Wed Aug 20
13:17:52 2014 UTC
@@ -6,7 +6,7 @@
namespace Cassia.Impl
{
/// <summary>
- /// Default implementation of <see cref="ITerminalServicesSession" />.
+ /// Default implementation of <see cref="ITerminalServicesSession"
/>.
/// </summary>
public class TerminalServicesSession : ITerminalServicesSession
{
@@ -31,6 +31,7 @@
private readonly GroupLazyLoadedProperty<IProtocolStatistics>
_outgoingStatistics;
private readonly LazyLoadedProperty<EndPoint> _remoteEndPoint;
private readonly ITerminalServer _server;
+ private readonly LazyLoadedProperty<IPAddress> _sessionIPAddress;
private readonly int _sessionId;
private readonly GroupLazyLoadedProperty<string> _userName;
private readonly GroupLazyLoadedProperty<string>
_windowStationName;
@@ -45,6 +46,7 @@
// Do this with GroupLazyLoadedProperty.
_clientBuildNumber = new
LazyLoadedProperty<int>(GetClientBuildNumber);
_clientIPAddress = new
LazyLoadedProperty<IPAddress>(GetClientIPAddress);
+ _sessionIPAddress = new
LazyLoadedProperty<IPAddress>(GetSessionIPAddress);
_remoteEndPoint = new
LazyLoadedProperty<EndPoint>(GetRemoteEndPoint);
_clientDisplay = new
LazyLoadedProperty<IClientDisplay>(GetClientDisplay);
_clientDirectory = new
LazyLoadedProperty<string>(GetClientDirectory);
@@ -60,8 +62,8 @@
// I haven't observed this in practice on Windows Server 2000,
2003, or 2008, but perhaps this
// should be considered.
var loader = IsVistaSp1OrHigher
- ? (GroupPropertyLoader) LoadWtsInfoProperties
- : LoadWinStationInformationProperties;
+ ? (GroupPropertyLoader) LoadWtsInfoProperties
+ : LoadWinStationInformationProperties;
_windowStationName = new
GroupLazyLoadedProperty<string>(loader);
_connectionState = new
GroupLazyLoadedProperty<ConnectionState>(loader);
_connectTime = new GroupLazyLoadedProperty<DateTime?>(loader);
@@ -163,6 +165,11 @@
{
get { return _clientIPAddress.Value; }
}
+
+ public IPAddress SessionIPAddress
+ {
+ get { return _sessionIPAddress.Value; }
+ }

public string WindowStationName
{
@@ -279,18 +286,18 @@
public void MessageBox(string text, string caption,
RemoteMessageBoxIcon icon)
{
MessageBox(text, caption, default(RemoteMessageBoxButtons),
icon, default(RemoteMessageBoxDefaultButton),
- default(RemoteMessageBoxOptions), TimeSpan.Zero,
false);
+ default(RemoteMessageBoxOptions), TimeSpan.Zero, false);
}

public RemoteMessageBoxResult MessageBox(string text, string
caption, RemoteMessageBoxButtons buttons,
- RemoteMessageBoxIcon
icon, RemoteMessageBoxDefaultButton defaultButton,
- RemoteMessageBoxOptions
options, TimeSpan timeout, bool synchronous)
+ RemoteMessageBoxIcon icon, RemoteMessageBoxDefaultButton
defaultButton, RemoteMessageBoxOptions options,
+ TimeSpan timeout, bool synchronous)
{
var timeoutSeconds = (int) timeout.TotalSeconds;
var style = (int) buttons | (int) icon | (int) defaultButton |
(int) options;
// TODO: Win 2003 Server doesn't start timeout counter until
user moves mouse in session.
var result = NativeMethodsHelper.SendMessage(_server.Handle,
_sessionId, caption, text, style,
- timeoutSeconds,
synchronous);
+ timeoutSeconds, synchronous);
// TODO: Windows Server 2008 R2 beta returns 0 if the timeout
expires.
// find out why this happens or file a bug report.
return result == 0 ? RemoteMessageBoxResult.Timeout : result;
@@ -300,7 +307,7 @@
{
var allProcesses = _server.GetProcesses();
var results = new List<ITerminalServicesProcess>();
- foreach (ITerminalServicesProcess process in allProcesses)
+ foreach (var process in allProcesses)
{
if (process.SessionId == _sessionId)
{
@@ -376,12 +383,12 @@
private void LoadWtsInfoProperties()
{
var info =
NativeMethodsHelper.QuerySessionInformationForStruct<WTSINFO>(_server.Handle,
_sessionId,
-
WTS_INFO_CLASS.WTSSessionInfo);
+ WTS_INFO_CLASS.WTSSessionInfo);
_connectionState.Value = info.State;
_incomingStatistics.Value = new
ProtocolStatistics(info.IncomingBytes, info.IncomingFrames,
-
info.IncomingCompressedBytes);
+ info.IncomingCompressedBytes);
_outgoingStatistics.Value = new
ProtocolStatistics(info.OutgoingBytes, info.OutgoingFrames,
-
info.OutgoingCompressedBytes);
+ info.OutgoingCompressedBytes);
_windowStationName.Value = info.WinStationName;
_domainName.Value = info.Domain;
_userName.Value = info.UserName;
@@ -395,13 +402,13 @@
private string GetClientName()
{
return
NativeMethodsHelper.QuerySessionInformationForString(_server.Handle,
_sessionId,
-
WTS_INFO_CLASS.WTSClientName);
+ WTS_INFO_CLASS.WTSClientName);
}

private string GetApplicationName()
{
return
NativeMethodsHelper.QuerySessionInformationForString(_server.Handle,
_sessionId,
-
WTS_INFO_CLASS.WTSApplicationName);
+ WTS_INFO_CLASS.WTSApplicationName);
}

private EndPoint GetRemoteEndPoint()
@@ -412,39 +419,39 @@
private string GetInitialProgram()
{
return
NativeMethodsHelper.QuerySessionInformationForString(_server.Handle,
_sessionId,
-
WTS_INFO_CLASS.WTSInitialProgram);
+ WTS_INFO_CLASS.WTSInitialProgram);
}

private string GetWorkingDirectory()
{
return
NativeMethodsHelper.QuerySessionInformationForString(_server.Handle,
_sessionId,
-
WTS_INFO_CLASS.WTSWorkingDirectory);
+ WTS_INFO_CLASS.WTSWorkingDirectory);
}

private ClientProtocolType GetClientProtocolType()
{
return
(ClientProtocolType)
-
NativeMethodsHelper.QuerySessionInformationForShort(_server.Handle,
_sessionId,
-
WTS_INFO_CLASS.WTSClientProtocolType);
+
NativeMethodsHelper.QuerySessionInformationForShort(_server.Handle,
_sessionId,
+ WTS_INFO_CLASS.WTSClientProtocolType);
}

private short GetClientProductId()
{
return
NativeMethodsHelper.QuerySessionInformationForShort(_server.Handle,
_sessionId,
-
WTS_INFO_CLASS.WTSClientProductId);
+ WTS_INFO_CLASS.WTSClientProductId);
}

private int GetClientHardwareId()
{
return
NativeMethodsHelper.QuerySessionInformationForInt(_server.Handle,
_sessionId,
-
WTS_INFO_CLASS.WTSClientHardwareId);
+ WTS_INFO_CLASS.WTSClientHardwareId);
}

private string GetClientDirectory()
{
return
NativeMethodsHelper.QuerySessionInformationForString(_server.Handle,
_sessionId,
-
WTS_INFO_CLASS.WTSClientDirectory);
+ WTS_INFO_CLASS.WTSClientDirectory);
}

private IClientDisplay GetClientDisplay()
@@ -460,11 +467,19 @@
_server.Handle, _sessionId,
WTS_INFO_CLASS.WTSClientAddress);
return
NativeMethodsHelper.ExtractIPAddress(clientAddress.AddressFamily,
clientAddress.Address);
}
+
+ private IPAddress GetSessionIPAddress()
+ {
+ var sessionAddress =
+
NativeMethodsHelper.QuerySessionInformationForStruct<WTS_SESSION_ADDRESS>(_server.Handle,
_sessionId,
+ WTS_INFO_CLASS.WTSSessionAddressV4);
+ return
NativeMethodsHelper.ExtractIPAddress(sessionAddress.AddressFamily,
sessionAddress.Address);
+ }

private int GetClientBuildNumber()
{
return
NativeMethodsHelper.QuerySessionInformationForInt(_server.Handle,
_sessionId,
-
WTS_INFO_CLASS.WTSClientBuildNumber);
+ WTS_INFO_CLASS.WTSClientBuildNumber);
}
}
}
Reply all
Reply to author
Forward
0 new messages