C# 如何知道我的应用程序是否由远程桌面控制?
事件描述 当当前登录的用户发生更改时发生 该属性有一个属性,告诉您事件的原因 如果远程桌面连接或断开连接,则引发此事件C# 如何知道我的应用程序是否由远程桌面控制?,c#,remote-desktop,C#,Remote Desktop,事件描述 当当前登录的用户发生更改时发生 该属性有一个属性,告诉您事件的原因 如果远程桌面连接或断开连接,则引发此事件 启动远程桌面时:Reason==SessionSwitchReason.RemoteConnect 远程桌面关闭时:原因==会话开关原因.RemoteDisconnect 如果在没有远程桌面的情况下启动程序,则属性IsRemoteSession为false。如果启动远程桌面,则会引发该事件,但该属性仍为false 但是,如果我用remote descktop启动程序,Is
- 启动远程桌面时:Reason==SessionSwitchReason.RemoteConnect
- 远程桌面关闭时:原因==会话开关原因.RemoteDisconnect
class ViewModel
{
public ViewModel()
{
SystemEvents.SessionSwitch += SessionSwitched;
IsRemoteSession = SystemParameters.IsRemoteSession;
Logger.LogTrace("ViewModel constructed. Remote Session {0}", this.IsRemoteSession);
}
public bool IsRemoteSession {get; set;}
private void SessionSwitched(object sender, SessionSwitchEventArgs e)
{
this.IsRemoteSession = SystemParameters.IsRemoteSession;
Logger.LogTrace("Session Switch. Reason: {0}; Remote Session {1}"
e.Reason, this.IsRemoteSession);
}