Thursday, August 11, 2011

Programming with Windows Screensaver

While developing your Windows application/system, you may want to disable/enable/deactivate the screensaver. Here are some ways to do so: (ref: http://support.microsoft.com/kb/140723)

If the screensaver is activated (because halting for some time) and you want to kill it (activate the machine), you may use the following C code:

To temporally disable screensaver (maybe your application is working on something and you do not want the screen to turn off automatically), you may use:

However, your system may go wrong using the above code. Imagine if your application crashed after disabling the screensaver, then it will keep disabled until you re-enable it manually. In this case, you can just set the state of your current thread to tell the system that this thread requires attention.

No comments:

Post a Comment