[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

Posted on 2004-10-21
5
Medium Priority
?
2,181 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
Comment
Question by:ewong_111
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 1500 total points
ID: 12374486
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
ID: 12374533
0
 
LVL 2

Author Comment

by:ewong_111
ID: 12374770
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
ID: 12383547
>>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
ID: 12384558
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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…

656 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