[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2196
  • Last Modified:

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

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
ewong_111
Asked:
ewong_111
  • 2
  • 2
1 Solution
 
jkrCommented:
Don't use the registry, use this API after impersonating:

SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, timeout_value,NULL,SPIF_UPDATEINIFILE);
0
 
ewong_111Author Commented:
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
 
jkrCommented:
>>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
 
ewong_111Author Commented:
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

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now