How to find out if hibernation is available for a Windows user (with C ++)

I know that to hibernate the system, you can call the following API:

SetSuspendState(TRUE, FALSE, FALSE);

But is there a way to find out if real hibernation is available for the current Windows user?

Here is what I mean:

  • If the administrator calls:

     powercfg.exe /hibernate off 

    The above API puts the system to sleep. So, how do you know (from a C ++ program) that this will happen instead of sleep mode?

  • I'm not sure if there is a group policy that can prevent a user from sleeping on a computer connected to Active Directory?

Edit I know the (dated) IsPwrHibernateAllowed API. I believe that it does not work: it still returns the same result, even if powercfg.exe /hibernate off was called. Am I doing something there? Can someone explain why IsPwrHibernateAllowed not working for me?

+4
source share
1 answer

Take a look at the SYSTEM_POWER_CAPABILITIES structure, which can be obtained using CallNtPowerInformation . In particular, see the HiberFilePresent field.

+4
source

Source: https://habr.com/ru/post/1385438/


All Articles