以编程方式确定锁定工作站的持续时间?

编程入门 行业动态 更新时间:2024-10-23 13:36:59
本文介绍了以编程方式确定锁定工作站的持续时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何通过代码确定机器被锁定了多长时间?

How can one determine, in code, how long the machine is locked?

也欢迎使用C#之外的其他想法。

Other ideas outside of C# are also welcome.

我喜欢Windows服务的想法(并接受了它)是为了简洁和整洁,但不幸的是,我认为它在这种情况下不适合我案件。我想在工作场所而不是在家(或者我想在家中)上在工作站上运行它,但是出于mod的考虑,这很难解决。实际上,这就是我自己滚动自己的原因的一部分。

I like the windows service idea (and have accepted it) for simplicity and cleanliness, but unfortunately I don't think it will work for me in this particular case. I wanted to run this on my workstation at work rather than home (or in addition to home, I suppose), but it's locked down pretty hard courtesy of the DoD. That's part of the reason I'm rolling my own, actually.

我还是会写下来,看看是否可行。谢谢大家!

I'll write it up anyway and see if it works. Thanks everyone!

推荐答案

我以前没有发现过,但是从任何应用程序中,您都可以连接SessionSwitchEventHandler。显然,您的应用程序将需要运行,但是只要它是运行状态即可:

I hadn't found this before, but from any application you can hookup a SessionSwitchEventHandler. Obviously your application will need to be running, but so long as it is:

Microsoft.Win32.SystemEvents.SessionSwitch += new Microsoft.Win32.SessionSwitchEventHandler(SystemEvents_SessionSwitch); void SystemEvents_SessionSwitch(object sender, Microsoft.Win32.SessionSwitchEventArgs e) { if (e.Reason == SessionSwitchReason.SessionLock) { //I left my desk } else if (e.Reason == SessionSwitchReason.SessionUnlock) { //I returned to my desk } }

更多推荐

以编程方式确定锁定工作站的持续时间?

本文发布于:2023-11-05 04:58:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1559967.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:工作站   持续时间   方式

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!