The command powercfg -requests
will provide a list of processes that are currently preventing a Windows 10 device from automatically entering sleep mode. However, the command requires administrator permissions. Asking for admin access just to perform a simple informational query seems far from ideal.
So is it possible to query the Windows 10 API for a similar list, in a user-space application?
These processes are passing SetThreadExecutionState()
the flags ES_SYSTEM_REQUIRED
or ES_DISPLAY_REQUIRED
. But I don't see any function to query a list of registered execution states.