Registry reflects changes, but the Screensaver properties box doesn't

I'm working on a project that will reset the current user's screensaver timeout time to one I specify.
I run the program and the registry reflects the settings I have set, but when I open the screensavers properties box there is no difference. I know I have the right registry key because I will manually change the value in the properties box and the registry immediately reflects the updates.

I've searched around a bit and all I found was that the changes will only take effect if the system is reboot which I know is wrong; there is an immediate update when you click the "Apply" button on the properties box. That is the effect I'm looking for. I have a program that will do this but I don't have the source for it, plus my company needs some additional functionality which I'm trying to add.

I know you can also use the SystemParametersInfo API, but I cannot get it to work right, so any examples of that working would be great.

Well, that about explains it! Any help would be fantastic! Thanks!

HERE'S THE RELATIVE CODE (THIS WILL CHANGE THE CURRENT USER'S SCREENSAVER TIMEOUT, BUT I NEED IT TO TAKE EFFECT IMMEDIATELY)

            Dim regStr As String = "Control Panel\Desktop\"
            Dim secKey As RegistryKey = Registry.CurrentUser.OpenSubKey(regStr, True)

            secKey.SetValue("ScreenSaveTimeOut", "120")

            secKey.Close()

************************************************************************************
EDIT: I upped the points to 500! This is really important to me! Thanks!
************************************************************************************
LVL 2
FIIS-VSOAsked:
Who is Participating?
 
Bob LearnedConnect With a Mentor Commented:
You need to broadcast a message indicating that a setting has changed.

Here is an example for setting a user environment variable:

Imports Win32 = Microsoft.Win32

Public Class UserEnvironment

  Private Declare Function SendMessageTimeout _
   Lib "user32" Alias "SendMessageTimeoutA" _
   (ByVal hwnd As Integer, ByVal msg As Integer, ByVal wParam As Integer, _
   ByVal lParam As String, ByVal fuFlags As Integer, ByVal uTimeout As Integer, _
   ByRef lpdwResult As Integer) As Integer

  Public Shared Sub SetValue(ByVal name As String, ByVal value As String)

    Const WM_SETTINGCHANGE& = &H1A&
    Const HWND_BROADCAST& = (-1)
    Const SMTO_ABORTIFHUNG& = &H2

    Dim regVersion As Win32.RegistryKey = Win32.Registry.CurrentUser.OpenSubKey("Environment", True)
    regVersion.SetValue(name, value)

    Dim rtnValue As Integer
    Dim result As Integer = SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0&, _
     "Environment", SMTO_ABORTIFHUNG, 5000&, rtnValue)

  End Sub

End Class

Bob
0
 
FIIS-VSOAuthor Commented:
Any examples of using the API call to change the screen saver timeout and broadcast the update message?
0
 
Bob LearnedCommented:
Did you get this solved, or do you still need help?

Bob
0
 
FIIS-VSOAuthor Commented:
Actually you answered my question in another topic I posted, but since I can't find out how to simply delete this post, I'll accept that answer above and give you some more points! Enjoy!

BTW: Here's a link to the other post with the answer I originally accepted:
<a href="http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/VB_DOT_NET/Q_21837908.html">http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/VB_DOT_NET/Q_21837908.html</a>
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.