Stop system entering 'standby'

跟風遠走 提交于 2019-12-05 16:14:51

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.

This article http://www.codeguru.com/cpp/w-p/system/messagehandling/article.php/c6907 provides a demo of how to do this from C++ (thought he article is framed as if you want to do it from Java, and provides a Java wrapper).

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

Hopefully it will give you enough of a direction to get started.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!