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.
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")