【问题标题】:How can we detect if particular user on system is RemoteDisconnected or not?我们如何检测系统上的特定用户是否已远程断开连接?
【发布时间】:2017-11-22 12:32:39
【问题描述】:

我的计划 Windows 服务在系统中运行。在其中,我想检测同一系统中的特定用户是否远程断开连接。

为了实现这一点,目前我正在重写 System.ServiceProcess.ServiceBase 类的 OnSessionChange(..) 方法以将状态写入文件以及何时写入 我需要检查状态,我从同一个文件中读取它。

但我想知道一种更好的检测方法而不将其存储在文件中?

class mySessionBase : ServiceBase
{
    protected override void OnSessionChange(SessionChangeDescription changeDescription)  
    {
        //Save the status of machine in file
         hangeDescription.Reason.ToString()
         changeDescription.SessionId
    }
}

是否有任何窗口远程 API 可用于检测相同的?

提前致谢

马亨

【问题讨论】:

标签: c# winapi windows-services window remote-desktop


【解决方案1】:

请参考下面的 WTSEnumerateSessions API 帮助我们获取会话和连接状态。

https://www.codeproject.com/Articles/111430/Grabbing-Information-of-a-Terminal-Services-Sessio

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-08-05
    • 1970-01-01
    • 1970-01-01
    • 2013-07-27
    • 1970-01-01
    • 2017-10-30
    • 2012-02-12
    • 2012-02-23
    相关资源
    最近更新 更多