c++ - Windows notifications when hibernation fails -


i'm coding using c++ winapis, , hibernate computer use following call:

setsuspendstate(true, null, false); 

but happens if computer has larger ram array installed hibernation fails.

so wondering, windows send notifications if hibernation fails? , if not, how tell if request hibernate failed?

looks there's no direct way detect hibernation [correction: wrong this. see fowl's answer.] until windows 8 (see powerregistersuspendresumenotification). suppose idle-loop , watch system time. if time jumps forwards, you've hibernated (and resumed!) , if hasn't happened within minute or request failed. think can use gettickcount64 function, insensitive system time changes apparently includes bias time spent sleeping. if doesn't work, use getsystemtimeasfiletime watch wm_timechange messages.

you check on system in question whether windows writes event log when hibernation fails. if so, application monitor event log relevant entry. more reliable approach.


Comments