public Sessions GetSessions() { Sessions colSessions = new Sessions(); try { oWTSSessions = oWTSCOM.WTSEnumerateSessions((int)ServerHandle); long SessionID; string SessionUser; long SessionState; string SessionName; foreach (WTSSession oWTSSession in oWTSSessions) { SessionID = oWTSSession.SessionId; SessionUser = oWTSCOM.WTSQuerySessionInformation((int)ServerHandle, oWTSSession.SessionId, 5); //WFUsername = 5 SessionState = oWTSSession.State; SessionName = oWTSSession.WinStationName + "\r\n"; if (SessionUser != "") { if (SessionState == 0) { colSessions.Add(SessionID, Language.strActive, SessionUser, SessionName); } else { colSessions.Add(SessionID, Language.strInactive, SessionUser, SessionName); } } } } catch (Exception ex) { Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, Language.strRdpGetSessionsFailed + Constants.vbNewLine + ex.Message, true); } return(colSessions); }
public Sessions GetSessions() { Sessions colSessions = new Sessions(); try { oWTSSessions = oWTSCOM.WTSEnumerateSessions((int)ServerHandle); long SessionID; string SessionUser; long SessionState; string SessionName; foreach (WTSSession oWTSSession in oWTSSessions) { SessionID = oWTSSession.SessionId; SessionUser = oWTSCOM.WTSQuerySessionInformation((int)ServerHandle, oWTSSession.SessionId, 5); //WFUsername = 5 SessionState = oWTSSession.State; SessionName = oWTSSession.WinStationName + "\r\n"; if (SessionUser != "") { if (SessionState == 0) { colSessions.Add(SessionID, Language.strActive, SessionUser, SessionName); } else { colSessions.Add(SessionID, Language.strInactive, SessionUser, SessionName); } } } } catch (Exception ex) { Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, Language.strRdpGetSessionsFailed + Constants.vbNewLine + ex.Message, true); } return colSessions; }