문제

I'm working on code that's supposed to start the screensaver defined by the user preferences. (The code is in Java, but will only be run under Windows.) My current approach is to set the ScreenSaveTimeOut value in the registry to 1; in theory, that should kick the screensaver on after a delay of merely one second.

But in practice, it does no such thing. I've hit the values in both HKEY_CURRENT_USER\Control Panel\Desktop\ScreenSaveTimeOut and HKEY_USERS.DEFAULT\Control Panel\Desktop\ScreenSaveTimeOut with no results. I can see the values change when I fire up regedit, but the "Wait" value in Display Properties -> Screen Saver doesn't change.

An Experts-Exchange thread indicated I ought to do this to make the changes effective immediately:

%SystemRoot%\System32\RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters

... but that didn't seem to do anything.

Any advice or insights into what I'm doing wrong?

도움이 되었습니까?

해결책

To activate the screen saver, you might find it easier just to execute the .SCR file with a '/s' parameter, like so:

C:\WINDOWS\system32\ssstars.scr /s

Or, I can't say much about how to do this from Java, but if you can call the functions in user32.dll you can control the screen saver like an end-user. Here are a couple links:

(Lastly, there's the .NET method, but again I have no idea how to get that from Java: http://zayko.net/post/C-How-To-Disable-Windows-Screensaver-programmatically.aspx)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top