?
Solved

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

Posted on 2006-05-03
4
Medium Priority
?
547 Views
Last Modified: 2012-06-27
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!
************************************************************************************
0
Comment
Question by:FIIS-VSO
  • 2
  • 2
4 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 1500 total points
ID: 16607776
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
 
LVL 2

Author Comment

by:FIIS-VSO
ID: 16609731
Any examples of using the API call to change the screen saver timeout and broadcast the update message?
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 16633451
Did you get this solved, or do you still need help?

Bob
0
 
LVL 2

Author Comment

by:FIIS-VSO
ID: 16651559
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

755 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question