c++winapiwindows-servicesscreensaverwindows-screensaver

How to refresh logon screensaver parameter changes?


I have a Windows service that may change the timeout on the logon screensaver in Windows (as described here.) To do that I change the following registry key to the timeout in seconds:

HKEY_USERS\.DEFAULT\Control Panel\Desktop\ScreenSaveTimeOut

The issue is that how do I make OS "read" or refresh the actual screensaver timeout after a change in the registry key above?

My practice shows that it is refreshed (for sure) only when I reboot the system, but in my case I need it to be applied without the reboot.

EDIT_1: After suggestion below I tried, as it seems to me, all possible combinations of the flags for the following:

DWORD bsmInfo1 = BSM_ALLDESKTOPS;
DWORD dwFlgs = BSF_FORCEIFHUNG | BSF_IGNORECURRENTTASK | BSF_NOTIMEOUTIFNOTHUNG | BSF_SENDNOTIFYMESSAGE;
int nbsm1 = ::BroadcastSystemMessage(dwFlgs, &bsmInfo1, WM_SETTINGCHANGE, 0, (LPARAM)L"Windows");
DWORD bsmInfo2 = BSM_ALLDESKTOPS;
int nbsm2 = ::BroadcastSystemMessage(dwFlgs, &bsmInfo2, WM_SETTINGCHANGE, 0, (LPARAM)L"WindowsThemeElement");

to no avail :( I receive 1 as a result from both calls but it has no effect.


Solution

  • I was able to resolve this.-.-.