Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Every time I boot my Win 7 system, the power keys are set to shut the system down. Every time, I reset the keys so that they cause the system to sleep. But sometimes I forget, and then programs are closed harshly.

I want to write a program that will force the power keys to cause the system to sleep rather than power down. Then I can run that program each time I boot, and I will avoid the problem.

Does anyone know the API calls to tell Win 7 that the power key should mean "sleep"?

share|improve this question
    
First of all, why was a programming question moved away from a programming site? Secondly, can anyone answer the actual question I asked? How do I write a program to set this OS parameter? –  jon Jul 23 '11 at 10:35
add comment

migrated from stackoverflow.com Jul 17 '11 at 11:22

This question came from our site for professional and enthusiast programmers.

1 Answer

Well, actually I don't think you need to make a program for this.
I'm using a laptop, but its the same Windows 7.
Go to the Control Panel, look for Power Options. then, choose you'r preferred power option, click Change plan settings and set whatever you want.
Next time you reboot, as long as you stay on that plan, the setting (e.g power button putting computer to sleep) should stay.

share|improve this answer
    
Thank you, but every time I do this, something changes it afterward. I need a way to override whatever is overriding my choices. –  jon Jul 16 '11 at 23:55
    
I think it's a windows-related problem, as long as you click save, it should stay that way. Contact Microsoft or something. –  Quantic Programming Jul 17 '11 at 9:33
    
Keep in mind, if you have pending updates, it will override the default wit shutdown. –  surfasb Jul 17 '11 at 16:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.