如何通过代码确定机器被锁定了多长时间?
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 } }更多推荐
以编程方式确定锁定工作站的持续时间?
发布评论