I'm developing a Screen Saver for a client which can be controlled remotely (don't ask!). They can change media types (namely videos and pictures), toggle the screen saver on and off, set its timeout, etc.
All of the above work except the timeout. The timeout works only when I restart the machine. Sometimes it works if I toggle between 3D Text screensaver, then back to my screen saver.
As of the .scr installation of this Screen Saver, I tried both possible ways: through registry and through InstallScreensaver facility inside user32.dll. I sticked to the first approach, as it is much easier.
As of the timeouts, I also tried a variety of things:
Updating
ScreenSaveTimeoutdirectly in the registry, then callingSystemParametersInfowith onlySPIF_SENDCHANGECalling
SystemParametersInfoonSPI_SETSCREENSAVETIMEOUTwith all combinations ofSPIF_SENDCHANGE,SPIF_UPDATEINIFILEand evenSPIF_SENDWININICHANGE
Either way I do it, the value gets updated in the Registry and when I open the Screen Saver Settings, the values are applied there, BUT!
But no matter what I do, it does not work after an immediate timeout change as I described above.
I even went far by calling:
rundll32.EXE user32.dll,UpdatePerUserSystemParameters
^ Both in my installation facilities, manually; and I can't remember what else I tried.
The background of the project is C# .NET Core 3.1 (another don't ask!), I use only two external dependencies, one of them is LibVLC for media playback, and the resource and memory consumption is very low.
What am I missing here?
PS Heck, I even changed file ownership to the SYSTEM account to see if that makes a difference, but to no avail.