I am writing c++ code. I am new to c++. I want to find system power state i.e if its offline/sleep/online etc i am trying to use SYSTEM_POWER_STATE enumeration . But can't find how to use it if some can write a short example or post a helpful link .
Thanks in advance
There's a wealth of info in MSDN about Power management.
List of power management functions with descriptions:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa373163(v=vs.85).aspx
And the usage samples:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa373243(v=vs.85).aspx
However, your question is a little strange: while you're sleeping you're... sleeping ! You can switch the system to Suspend mode, but your software is not running while the system sleeps. So please clarify your question if you want some more specific info. If you're writing a system service or a driver, this makes more sense, but still it is not clear from the question.
To get the power status (battery load, power source) use the GetSystemPowerStatus.
And one more thing. If you're talking about the Windows CE, then here you go: GetSystemPowerState. You didn't tell about WinCE either :)