Changing Screen Saver settings in registry under HKEY_CURRENT_USER as a Windows Service

Posted on 2004-10-21
Last Modified: 2013-12-03

I am trying to change the screen saver settings for the current logged on user in the registry.

Here's what I did:
- use EnumProcesses to pull up all the active processes
- get the process id of explorer.exe
- use OpenProcess and OpenProcessToken and ImpersonateLoggedOnUser on the current thread
- use RegCreateKeyEx and RegSetValueEx for setting values

Here's the problem
- The values in the registry under HKEY_CURRENT_USER did not change
- Only the values under HKEY_USERS\.DEFAULT and HKEY_USERS\S-x-x-xx changed

My ultimate goal is to enforce the screen saver timeout period of the currently logged on user 24/7, am I missing something or is it just the way it is?
Any help or suggestion is appreciated..
Question by:ewong_111
    LVL 86

    Accepted Solution

    Don't use the registry, use this API after impersonating:

    LVL 48

    Expert Comment

    LVL 2

    Author Comment


    Thanks a lot.
    But the SPI_SETSCREENSAVEACTIVE parameter doesn't make the screen saver active.
    Am I still missing anything?
    Is it because my screen saver was inactive and the "SCRNSAVE.EXE" key was removed and therefore it doesn't work?
    Also, I don't see any parameter to set the "password protected" feature, is it possible to set that too?
    Thanks a million.
    LVL 86

    Expert Comment

    >>But the SPI_SETSCREENSAVEACTIVE parameter doesn't make the screen saver active

    Um, I thought you wanted to set the timeout?

    >>Also, I don't see any parameter to set the "password protected" feature.

    Yup, couldn't find one either. BTW, HKEY_CURRENT_USER in fact only is a shortcut/link to HKEY_USERS\S-x-x-xx
    LVL 2

    Author Comment

    yeah.. I only asked for setting the timeout at the beginning..
    may be I should just start another question asking how to activate the screen saver for the currently logged on user..
    and I would say it's strange that the values in the HKEY_CURRENT_USER and HKEY_USERS\S-x-x-xx are different for the screen saver part after I have used the SystemParameterInfo to change it.. is it cached in the memory some how?
    and also I just can't make the screen saver active.. don't know why..

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
    Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
    In this Experts Exchange video Micro Tutorial, I'm going to show how small business owners who use Google Apps can save money by setting up what is called a catch-all email address in their Gmail accounts. By using the catch-all feature, small busin…

    877 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

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now