问题
I have created a .NET Windows application in C#. I want to execute this application when the system becomes idle for sometime. The application is a user login application, i.e. when system becomes idle for sometime, a login page appears where the user logins with his username and password. Then only the user can continue using the system.
How can I make it work out? Please help as I am new in Windows applications.
I thought to run the application as a Windows service. I managed to run the application on Windows service start. But how can I trigger the app to run only when system goes to idle in Windows service? I also need to start the timer after the user logins to check idle time again. Please provide some code examples.
回答1:
This tutorial describes a method of getting the system idle time via the win32 API.
回答2:
The system already comes with such functionality. On the screen saver configuration page you simply check the box titled "On resume, display logon screen". It can be configured with group policy.
There's absolutely no point re-implementing this.
回答3:
How about:
- Start your form hidden
- Get the system idle time
- Show your window.
回答4:
You can do this with the new Task Scheduler in Windows Vista and Windows 7. See, for example, "Task Idle Conditions".
回答5:
So it looks like you want screen saver sample - look at http://msdn.microsoft.com/en-us/library/ms686421(VS.85).aspx and http://www.codeproject.com/KB/cs/ScreenSaverStarterKit.aspx.
I don't think that you want to create custom Windows login based on your comment, but here is an article to get you strted learning about it http://msdn.microsoft.com/en-us/magazine/cc163489.aspx.
EDIT: and here is how to start screensaver via code: Launch System Screensaver from C# Windows Form
来源:https://stackoverflow.com/questions/5151011/how-to-run-a-net-application-when-the-system-becomes-idle