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

1.2k Views Asked by At

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

SetSuspendState(TRUE, FALSE, FALSE);

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

Here's what I mean:

  1. If an admin calls:

    powercfg.exe /hibernate off
    

    the API above will put system into a Sleep mode. So how do you know (from a C++ program) that this will happen instead of hibernation?

  2. I'm not sure if there's a group policy that can prohibit a user from hibernating a computer connected to an Active Directory?

Edit I am aware of the (dated) IsPwrHibernateAllowed API. I find that it doesn't work: it still returns the same result even if powercfg.exe /hibernate off was called. Am I doing something wrong there? Can someone explain why IsPwrHibernateAllowed doesn't work for me?

1

There are 1 best solutions below

3
Violet Giraffe On BEST ANSWER

Take a look at SYSTEM_POWER_CAPABILITIES structure that can be obtained with CallNtPowerInformation. Specifically, look at HiberFilePresent field.