?
=?ISO-8859-1?Q?M=E9sz=E1ros_Tam=E1s?=
Hi!
I want to get information about the state of TS-Sessions, and I've tried
it the following way:
------------------------------------------------------
enum WTS_CONNECTSTATE_CLASS
{
WTSActive,
WTSConnected,
TSConnectQuery,
WTSShadow,
WTSDisconnected,
WTSIdle,
WTSListen,
WTSReset,
WTSDown,
WTSInit
};
struct WTS_SESSION_INFO
{
public int SessionId;
public string pWinStationName;
public WTS_CONNECTSTATE_CLASS State;
}
[DllImport("wtsapi32")]
private static extern bool WTSEnumerateSessions(int hServer, int
reserved, int version, ref WTS_SESSION_INFO[] ppSessionInfo, ref int Count);
....
WTS_SESSION_INFO[] ppSessionInfo = new WTS_SESSION_INFO[20];
/*I must initialize it, because I can't pass it to a function
uninitialized*/
int Count = 0;
WTS_SESSION_INFO wts;
WTSEnumerateSessions(0, 0, 1, ref ppSessionInfo, ref Count );
....
-----------------------------------------------------------------------
After the WTSEnumerateSessions function returns, I can find the correct
number in the Count variable, but the ppSessionInfo allways has only one
element and it doesn't contain any information about the other sessions.
Could someone correct this code-part or send me a working example?
Thanks in advance,
Tamas Meszaros
I want to get information about the state of TS-Sessions, and I've tried
it the following way:
------------------------------------------------------
enum WTS_CONNECTSTATE_CLASS
{
WTSActive,
WTSConnected,
TSConnectQuery,
WTSShadow,
WTSDisconnected,
WTSIdle,
WTSListen,
WTSReset,
WTSDown,
WTSInit
};
struct WTS_SESSION_INFO
{
public int SessionId;
public string pWinStationName;
public WTS_CONNECTSTATE_CLASS State;
}
[DllImport("wtsapi32")]
private static extern bool WTSEnumerateSessions(int hServer, int
reserved, int version, ref WTS_SESSION_INFO[] ppSessionInfo, ref int Count);
....
WTS_SESSION_INFO[] ppSessionInfo = new WTS_SESSION_INFO[20];
/*I must initialize it, because I can't pass it to a function
uninitialized*/
int Count = 0;
WTS_SESSION_INFO wts;
WTSEnumerateSessions(0, 0, 1, ref ppSessionInfo, ref Count );
....
-----------------------------------------------------------------------
After the WTSEnumerateSessions function returns, I can find the correct
number in the Count variable, but the ppSessionInfo allways has only one
element and it doesn't contain any information about the other sessions.
Could someone correct this code-part or send me a working example?
Thanks in advance,
Tamas Meszaros