Link to home
Start Free TrialLog in
Avatar of RobertFromSecretWeapons
RobertFromSecretWeapons

asked on

Preventing Standby, Sleep modes from happening while an application runs.

When my application runs, I have a requirement to prevent a system from entering Standby, etc.  The reason for this is that it loses connection to the remote host.

So, while my application runs, I need to prevent any kind of standby event from occuring.  When my application ends, I need to resume whatever the state was of the power management system.
Avatar of scrathcyboy
scrathcyboy
Flag of United States of America image

YOU CANNOT DO THIS !! -- power management is based on user settings -- NOT on applications running.

To disable power management, right click desktop, properties, screen saver, turn off all screen savers, and then click the power button, set everything in that screen to "always on", monitor, hard disks, and disable system standby.

Now just LEAVE IT THAT WAY -- this idea of windows power management is basically BS for a desktop -- you simply DO NOT need it -- the only time you need it is on a laptop on batteries.

If this is what your users have, you might as well forget it, there is no way to do this based on the running of an application, and reset it afterwards.  This is a setting RESERVED FOR THE USER to set for himself, based on how he wnats to use the computer, the apps cannot control this, the user does.
ASKER CERTIFIED SOLUTION
Avatar of cheddar73
cheddar73

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
"YOU CANNOT DO THIS !! -- power management is based on user settings -- NOT on applications running."

This is M$'s model for XP -- it is an inviobale rule they have set down, it is totally USER CONTROLLED !!!
Avatar of cheddar73
cheddar73

But I just did it.  I set my power options to hibernate after 2 minutes.  Then I left the machine alone to make sure it would.  It did.

Then I ran this code:

Do While True
    SetThreadExecutionState(ES_SYSTEM_REQUIRED)
Loop

I came back after 10 minutes and the system was not hibernating.

I have read on some blog somewhere (which I can't find now) that it doesn't work on Vista, but it certainly does on XP.
Avatar of RobertFromSecretWeapons

ASKER

This souldn't cause such a commotion.  There are times when it's important NOT to have the PC go into Standy.  It most surely does while my host connected application is running.  It's a real time data feed.  Once PC goes into Standy, host connection gets killed.