How to check if the system is in standby mode?

I want to check if the system is idle, is there a Win32 API for this? I'm not sure if it's the same as hibernation.

There's some code in there that runs in my application that makes it hang when coming out of standby (it runs in standby), so I would not want to run this code when the computer is sleeping / standing.

Thanks in advance!

Dennis

edit: it might not be possible because the program shouldn't work as stated in the answer below, so I'll count that as an answer :)

+1


source to share


3 answers


When the system is in standby mode, the program will not run, so the following will be fine:

int is_in_standby() {
  return 0;
}

      



Or am I missing something?

+4


source


As far as I know, none of the code works in Windows standby. Apart from RAM, everything is turned off. The error in your code can be caused by window messages after the computer wakes up again.



+1


source


If your program is running, you are not in standby mode.

I think you want to handle WM_POWERBROADCAST messages . They will tell you when the system changes its power state, and before Vista you can get angry and veto the system shutdown if you want.

0


source







All Articles