5

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?

Gorpik
  • 10,940
  • 4
  • 36
  • 56
ahmd0
  • 16,633
  • 33
  • 137
  • 233
  • 2
    Google "IsPwrHibernateAllowed" – Hans Passant Dec 08 '11 at 23:16
  • http://msdn.microsoft.com/en-us/library/windows/desktop/aa373163(v=vs.85).aspx – parapura rajkumar Dec 08 '11 at 23:18
  • @Hans Passant IsPwrHibernateAllowed is an outdated API, but it still returns the same result even if powercfg.exe /hibernate off was called. I also scoured all over those Power Management Functions with any luck (( – ahmd0 Dec 08 '11 at 23:29
  • @ahmd0: That kind of information should obviously have been in the question! Prevent people from wasting time coming up with the obvious answers that you already tried? – sehe Dec 09 '11 at 07:57
  • Good addition. So, can you answer your question? – ahmd0 Dec 09 '11 at 08:14

1 Answers1

4

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

Violet Giraffe
  • 32,368
  • 48
  • 194
  • 335