You have to choose between using JwaWindows (which is really a single
unit containing all other Jwa units) or using JwaWtsApi32. I recommend using JwaWindows in your case.
Note that the
Jedi security library (
Jwscl) contains a
Terminal Server unit that wraps all Terminal Server
API's. This makes your question really simple:
Delphi-Quellcode:
uses JwsclTerminalServer;
...
var
TS: TJwTerminalServer;
TS := TJwTerminalServer.Create;
// You should check for errors and/or exceptions (see [url=http://jwscldoc.delphi-jedi.net/JwsclTerminalServer.TJwTerminalServer.html]documentation[/url]) but left out here to shorten code
TS.EnumerateSessions;
ShowMessageFmt('
%d Terminal Sessions', TS.Sessions.Count);
TS.Free;
The Connectstate property can be used to filter specific sessions (eg only active ones), from the docs:
ConnectState returns the connection state of the session. Which can be one of the following values:
Session State Description
WTSActive The session is connected, and a user is logged on to the server.
WTSConnected The session is connected, but there is no user logged on to the server.
WTSConnectQuery The session is in the process of connecting. If this state continues, it indicates a problem with the connection.
WTSShadow The session is in the process of remotely controlling another session.
WTSDisconnected The user is disconnected from the session, but the session is still attached to the server and can be reconnected at any time.
WTSIdle The session is initialized and ready to accept a connection. To optimize the performance of a server, two default (idle) sessions are initialized before any client connections are made.
WTSReset The session failed to initialize correctly or could not be terminated, and is not available. If this state continues, it indicates a problem with the connection of the session.
WTSInit The session is in the process of initializing.