Solved

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

Posted on 2004-10-21
2,169 Views
Last Modified: 2013-12-03
Hi,

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..
0
Question by:ewong_111
    5 Comments
     
    LVL 86

    Accepted Solution

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

    SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, timeout_value,NULL,SPIF_UPDATEINIFILE);
    0
     
    LVL 48

    Expert Comment

    by:Mikal613
    0
     
    LVL 2

    Author Comment

    by:ewong_111
    jkr,

    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.
    0
     
    LVL 86

    Expert Comment

    by:jkr
    >>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
    0
     
    LVL 2

    Author Comment

    by:ewong_111
    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..
    0

    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. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
    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