本文介绍了检查用户空闲时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要编写一个应用程序或Web服务,以检查用户RDP-TCP会话是否空闲,以及是否空闲-关闭另一个应用程序.

但是我不知道在哪里可以找到空闲时间. "Windows任务管理器"没有显示空闲时间,但是远程桌面服务管理器"却显示了.

所以我的问题是

i need to write an application or web service, that checks if users RDP-TCP session is idle, and if its idle - close another application.

but i cannot figure out where to find the idle-time -> "windows task manager" does not show an idle time, but "remote desktop services manager" does.

so my question is

does anybody know where i can find out if the logged on users are idle or not?

推荐答案



ITerminalServicesManager manager = new TerminalServicesManager();
            using (ITerminalServer server = manager.GetLocalServer())
            {
                server.Open();
                foreach (ITerminalServicesSession session in                    server.GetSessions())
                {
                    NTAccount account = session.UserAccount;
                    if (session.IdleTime > minutes && account != null && account.ToString().Contains("admin") == false)
                    {

                        listBox1.Items.Add(session.UserAccount + " " + DateTime.Now.ToString());
                        session.Disconnect();
                        Settings.Default.amount++;
                        Settings.Default.Save();
                        label1.Text = "Accounts disconnected: " + Settings.Default.amount.ToString();
                    }
                    else { }
                }

            }


这篇关于检查用户空闲时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 10:09