Continue running when PC wakes up.

Hi all,

This is my first post here and I am very new to C++.
I'm not too sure how easy this is to do and I have searched the internet and this forum but I have been unable to come to a solid answer.

I have a windows PC (possibly moving to Linux soon) that will run a console application continuously. The program runs at startup, and continues to run until the PC is shut down.
However, the PC goes into sleep mode frequently in order to avoid using too much power and resource. I need my program console to display a message when the PC resumes/wakes up.

Basic example;

1
2
3
  if (pcWake = true) {
     cout << "Welcome Back\n"
  }


That's effectively what I would like it to do, and I can't seem to put my finger on it and I am not 100% sure where to start. I have spent a good few days searching to no avail.

Any help would be greatly appreciated.

Thank you very much in advance!

Chris
normal applications should be handled by the operating system, and will wake up and resume when the computer is poked. I don't think you have to DO anything.

As for detecting wakeup, I think that is OS specific. Youll need to look deep in the windows or other os libraries, but I don't know what that is.

However, a dumb timer would work fine. Get the current date and time. If its more than however long since you last did that, you have been asleep, print a message!

try reading this, but ill warn you straight up, the windows libraries are a whole 'nother layer on top of c++ coding.

http://stackoverflow.com/questions/11944335/is-windows-entering-sleep-mode-or-hibernating-with-c
Last edited on
Topic archived. No new replies allowed.