SetThreadExecutionState / CallNtPowerInformation(SystemExecutionState)



I would be very grateful if anyone could answer the following:

1. I'm using SetThreadExecutionState with flags ES_SYSTEM_REQUIRED and
ES_CONTINUOUS to prevent a system from sleeping. When I don't need the
system to stay awake anymore I call it again with only ES_CONTINUOUS set -
my understanding is that this clears the previous flags and allows the idle
counter to start working again. Sometimes however, the system still refuses
to idle after the second call - Is it possible that calling again with only
ES_CONTINUOUS set would reset the idle timer again (I don't do this very
frequently but possible once every few minutes)?

Or, to put it another way:

2. You can determine the current state by calling
CallNtPowerInformation(SystemExecutionState, ...) .If this reports that
ES_SYSTEM_REQUIRED (or similar) is set is there anyway to find which thread
(or even better just which process) has done this. I have a situation where
something is setting the flag but I don't seem to have anyway to find out
what.


Best Regards

James


.



Relevant Pages