c++winapistandardsstandby

Stop system entering 'standby'


How can i stop the host machine entering standby mode while my application is running?

Is there any win32 api call to do this?


Solution

  • There are two APIs, depending on what version of Windows.

    XP,2000, 2003:

    http://msdn.microsoft.com/en-us/library/aa373247(VS.85).aspx

    Respond to PBT_APMQUERYSUSPEND.

    Vista, 2008:

    http://msdn.microsoft.com/en-us/library/aa373208(VS.85).aspx

    There could be many valid reasons to prevent the computer from going to sleep. For example, watching a video, playing music, compiling a long running build, downloading large files, etc.