0

Possible Duplicate:
Prevent windows from going into sleep when my program is running?

Hello all

What can I do to change windows power options in a Delphi app? I want to disable the hibernate and suspend power options.

I have a Delphi app that does a lot or processing in background, and when windows hibernate or suspend my application stops processing.

Community
  • 1
  • 1
Rafael Colucci
  • 5,896
  • 4
  • 48
  • 115
  • 1
    You need to persuade Windows not to hibernate or suspend, rather than change the users settings. SetThreadExecutionState, or SendInput with a 0,0 mouse move are what you need. – David Heffernan Apr 01 '11 at 13:15
  • 1
    As David says, you're not supposed to change the user's settings. This is in fact something often done by multimedia applications, to prevent Windows from going to sleep while you're watching a movie or listening to music. – Cosmin Prund Apr 01 '11 at 13:19
  • 1
    That is not duplicate, since the link is a c# code and i need a delphi code – Rafael Colucci Apr 01 '11 at 13:34
  • @David can you provide a sample code? – Rafael Colucci Apr 01 '11 at 13:35
  • You should be able to translate it yourself – David Heffernan Apr 01 '11 at 13:44
  • @Rafael Check this link http://delphi.about.com/od/delphitips2008/qt/nosleep.htm – RRUZ Apr 01 '11 at 13:55
  • Also you can check the `Windows Power Management Functions` http://msdn.microsoft.com/en-us/library/aa373163%28v=VS.85%29.aspx – RRUZ Apr 01 '11 at 13:56
  • @RRUZ make it an answer and I will accept it. Thanks. – Rafael Colucci Apr 01 '11 at 16:22
  • 1
    Rafael, the linked question is not specific to any particular language. It's a general Windows question. The answer happens to be in C, but if you're every going to survive as a Windows programmer, you need to understand how to read C. You do it every day when you refer to MSDN. – Rob Kennedy Apr 01 '11 at 16:34

0 Answers0