SessionChangeReason Enum
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Specifies the reason for a Terminal Services session change notice.
public enum class SessionChangeReason
public enum SessionChangeReason
type SessionChangeReason =
Public Enum SessionChangeReason
- Inheritance
Fields
ConsoleConnect | 1 | A console session has connected. |
ConsoleDisconnect | 2 | A console session has disconnected. |
RemoteConnect | 3 | A remote session has connected. |
RemoteDisconnect | 4 | A remote session has disconnected. |
SessionLock | 7 | A session has been locked. |
SessionLogoff | 6 | A user has logged off from a session. |
SessionLogon | 5 | A user has logged on to a session. |
SessionRemoteControl | 9 | The remote control status of a session has changed. |
SessionUnlock | 8 | A session has been unlocked. |
Examples
The following code example shows the use of the SessionChangeReason enumeration in an implementation of the OnSessionChange method in a class derived from ServiceBase. This code example is part of a larger example provided for the ServiceBase class.
// Handle a session change notice
protected override void OnSessionChange(SessionChangeDescription changeDescription)
{
#if LOGEVENTS
EventLog.WriteEntry("SimpleService.OnSessionChange", DateTime.Now.ToLongTimeString() +
" - Session change notice received: " +
changeDescription.Reason.ToString() + " Session ID: " +
changeDescription.SessionId.ToString());
#endif
switch (changeDescription.Reason)
{
case SessionChangeReason.SessionLogon:
userCount += 1;
#if LOGEVENTS
EventLog.WriteEntry("SimpleService.OnSessionChange",
DateTime.Now.ToLongTimeString() +
" SessionLogon, total users: " +
userCount.ToString());
#endif
break;
case SessionChangeReason.SessionLogoff:
userCount -= 1;
#if LOGEVENTS
EventLog.WriteEntry("SimpleService.OnSessionChange",
DateTime.Now.ToLongTimeString() +
" SessionLogoff, total users: " +
userCount.ToString());
#endif
break;
case SessionChangeReason.RemoteConnect:
userCount += 1;
#if LOGEVENTS
EventLog.WriteEntry("SimpleService.OnSessionChange",
DateTime.Now.ToLongTimeString() +
" RemoteConnect, total users: " +
userCount.ToString());
#endif
break;
case SessionChangeReason.RemoteDisconnect:
userCount -= 1;
#if LOGEVENTS
EventLog.WriteEntry("SimpleService.OnSessionChange",
DateTime.Now.ToLongTimeString() +
" RemoteDisconnect, total users: " +
userCount.ToString());
#endif
break;
case SessionChangeReason.SessionLock:
#if LOGEVENTS
EventLog.WriteEntry("SimpleService.OnSessionChange",
DateTime.Now.ToLongTimeString() +
" SessionLock");
#endif
break;
case SessionChangeReason.SessionUnlock:
#if LOGEVENTS
EventLog.WriteEntry("SimpleService.OnSessionChange",
DateTime.Now.ToLongTimeString() +
" SessionUnlock");
#endif
break;
default:
break;
}
}
' Handle a session change notice
Protected Overrides Sub OnSessionChange(ByVal changeDescription As SessionChangeDescription)
#If LOGEVENTS Then
System.Diagnostics.EventLog.WriteEntry("SimpleService.OnSessionChange", DateTime.Now.ToLongTimeString() + " - Session change notice received: " + changeDescription.Reason.ToString() + " Session ID: " + changeDescription.SessionId.ToString())
#End If
Select Case changeDescription.Reason
Case SessionChangeReason.SessionLogon
userCount += 1
#If LOGEVENTS Then
System.Diagnostics.EventLog.WriteEntry("SimpleService.OnSessionChange", DateTime.Now.ToLongTimeString() + " SessionLogon, total users: " + userCount.ToString())
#End If
Case SessionChangeReason.SessionLogoff
userCount -= 1
#If LOGEVENTS Then
System.Diagnostics.EventLog.WriteEntry("SimpleService.OnSessionChange", DateTime.Now.ToLongTimeString() + " SessionLogoff, total users: " + userCount.ToString())
#End If
Case SessionChangeReason.RemoteConnect
userCount += 1
#If LOGEVENTS Then
System.Diagnostics.EventLog.WriteEntry("SimpleService.OnSessionChange", DateTime.Now.ToLongTimeString() + " RemoteConnect, total users: " + userCount.ToString())
#End If
Case SessionChangeReason.RemoteDisconnect
userCount -= 1
#If LOGEVENTS Then
System.Diagnostics.EventLog.WriteEntry("SimpleService.OnSessionChange", DateTime.Now.ToLongTimeString() + " RemoteDisconnect, total users: " + userCount.ToString())
#End If
Case SessionChangeReason.SessionLock
#If LOGEVENTS Then
System.Diagnostics.EventLog.WriteEntry("SimpleService.OnSessionChange", DateTime.Now.ToLongTimeString() + " SessionLock")
#End If
Case SessionChangeReason.SessionUnlock
#If LOGEVENTS Then
System.Diagnostics.EventLog.WriteEntry("SimpleService.OnSessionChange", DateTime.Now.ToLongTimeString() + " SessionUnlock")
#End If
Case Else
End Select
End Sub
Applies to
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기