• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2201
  • 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
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.

Join & Write a Comment

Featured Post

Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

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