I know I took this code out before, but it's been pointed out to me that handling the SC_SCREENSAVE WM_SYSCOMMAND message doesn't work on Vista any more. Don't know why.
Rbraz, can you please add in the following to the startup and shutdown routines?
static BOOL screen_save_active;
static void disable_screensaver(void)
{
SystemParametersInfo(SPI_GETSCREENSAVEACTIVE, 0, &screen_save_active, 0);
SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, FALSE, NULL, 0);
DWORD dwReturnValue;
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETSCREENSAVEACTIVE, (LPARAM)"Desktop", SMTO_ABORTIFHUNG, 5000, &dwReturnValue);
SetThreadExecutionState(ES_DISPLAY_REQUIRED|ES_CONTINUOUS);
}
static void enable_screensaver(void)
{
SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, screen_save_active, NULL, 0);
DWORD dwReturnValue;
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETSCREENSAVEACTIVE, (LPARAM)"Desktop", SMTO_ABORTIFHUNG, 5000, &dwReturnValue);
}
This version is slightly more friendly than the one that was removed - it tells other apps that we've changed a setting, and restores the setting when we've finished.
Cheers!
Jim