How can i stop the host machine entering 'standby' mode while my application is running?
Is there any win32 api call to do this?
How can i stop the host machine entering 'standby' mode while my application is running?
Is there any win32 api call to do this?
would you want a win32api call to do this?
The user is supposed to be in control of his machine, so his rules should apply.
How does the user specify when his machine goes into 'standby'?
Ofcourse the user has control. The application will have a setting which can be set 'Allow entering into standby'
I have seen some drivers has this capability, like displaying a messagebox stating that the xxxx is running, and it is blocking the system to enter standby. Cant recall which one was it.
But i wonder how they manage to do. I so much hoped there would be win32 api call.. :(
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.
Here is a discussion of exactly this issue. I believe the links in the discussion should help you out. But it seems that it was possible to prevent this in XP, but it is no longer possible to prevent this under Vista when the user explicitly requests standby.
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.
Thanks Brannon, I guess, you answered my question :)
Also found that GetSystemPowerStatus lets you know if the system is running on batteries or main.