I'm coding this user-mode executable that can be run from a local service on a Windows platform in a context of logged in users. Its main purpose is to configure a desktop of all logged in users. It calls the following API to set up screensaver:
if(!SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, nTimeoutSec, 0, 0))
{
//Error
GetLastError();
}
if(!SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, nActive, 0, 0))
{
//Error
GetLastError();
}
The code above works in most cases, except at times when I have more than one user logged on to the Windows console I get this weird error ERROR_OPERATION_IN_PROGRESS. I looked up the documentation and it has this explanation:
If the machine has entered power saving mode or system lock state, an ERROR_OPERATION_IN_PROGRESS exception occurs.
OK, but how shall I treat this error?
PS. This happens most often on Windows 8.
SPI_SETSCREENSAVEACTIVE
can produce some error and do nothing. Try to send aWM_SYSCOMMAND
withSC_SCREENSAVE
message to theGetDesktopWindow()
window.