System Standby

How can I stop the host computer entering standby mode while my application is running?

Is there a win32 api call for this?

+4
source share
2 answers

Depending on the version of Windows, there are two APIs.

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 can be many good reasons for the computer not to fall asleep. For example, watching videos, playing music, compiling a lengthy build, downloading large files, etc.

+6
source

This article http://www.codeguru.com/cpp/wp/system/messagehandling/article.php/c6907 demonstrates how to do this with C ++ (thought the article was written as if you want to do it is from Java and provides a Java shell).

The actual code in the zip file is at http://www.codeguru.com/dbfiles/get_file/standbydetectdemo_src.zip?id=6907&lbl=STANDBYDETECTDEMO_SRC_ZIP&ds=20040406 , and part of C ++ is in com / ha / common / windows / standbydetector.

Hope this gives you enough start to get started.

+3
source

Source: https://habr.com/ru/post/1276643/


All Articles