Another addition to the solution...
Instead of restarting, try a call to UpdatePerUserSystemParameters to make the change effective.
You can simply test it by using the code you already got and execute the line below in the command window. After that, the value in the GUI should be updated as well.
%SystemRoot%\System32\RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters