Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable and Enable Screen Saver in Windows 7

I have an application than disables the screen saver temporarily in order to run a slide show. I use this to turn it on or off:

i = SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, active, Nothing, SPIF_SENDWININICHANGE)

This works fine in XP. In Windows 7, it disables the screen saver properly. However, when it is enabled again, at the normal time for the screen saver to come on, the system asks for a password instead of showing the screen saver.

From this time on until the screen saver settings are adjusted in the control panel, the password screen is displayed in place of the screen saver.

Is there something else I should be doing for Windows 7? I understand that SPI_GETSCREENSAVEACTIVE is not supported in Windows 7, but SPI_SETSCREENSAVEACTIVE is supposed to be.

like image 916
xpda Avatar asked Jan 18 '10 17:01

xpda


People also ask

How do I turn on screensaver in Windows 7?

In Windows 7 and Vista, from the Start menu, click Control Panel. In the Control Panel, click Appearance and Personalization. Under "Personalization", click Change screen saver. In the "Screen saver" section of the resulting window, from the pull-down menu, select your desired screen saver.

How do I enable my screen saver?

Go to Settings > Personalization > Lock screen, and select Screen saver settings. In the Screen Saver Settings window, choose a screen saver from the drop-down list.

How do I manually start my screensaver in Windows 7?

Right-click on the desktop, choose Personalize, and then click on Screen Saver on the bottom right-hand side of the window.


1 Answers

The solution is to change the registry value HKCU\Control Panel\Desktop ScreenSaveActive key instead of using SystemParametersInfo. This works in both XP and Windows 7.

Call Registry.SetValue("HKEY_CURRENT_USER\Control Panel\Desktop", "ScreenSaveActive", "1")
like image 141
xpda Avatar answered Sep 23 '22 14:09

xpda