[Psi-devel] RC1 vs. suspend

Michał Jazłowiecki michalj at poczta.neostrada.pl
Sat Jun 23 11:15:36 PDT 2007


Hello,


I've conducted some investigation around hibernation in Windows 
operating systems.

Yesterday I run an in-depth search through power management section of 
Platform SDK documentation, but found no evidence of any message that 
might be sent when system hibernates or is restored from hibernation.

Today I've decided to write as small as possible Windows application 
that will log all messages it receives to a file. This application 
wasn't small at all (exactly 100 lines of C++ code), but did the trick. 
And here are the information I have found in my application's log file:


Just before the system hibernates, WM_POWERBROADCAST message is sent 
with PBT_APMSUSPEND as wParam and 0 as lParam.

This message can be sent (or rather broadcasted to all applications) by 
a call to SetSystemPowerState (BOOL fSuspend, BOOL fForce) WinAPI 
function. The first parameter tells whether system should be suspended 
(fSuspend = TRUE) or hibernated (fSuspend = FALSE). This parameter is 
ignored on Windows 95/98/Me. The second parameter tells whether 
WM_POWERBROADCAST with PBT_APMQUERYSUSPEND (allowing for applications to 
deny the system from entering suspend or hibernation) will be sent.


After system is restored from hibernation, WM_POWERBROADCAST message is 
sent with PBT_APMPOWERSTATUSCHANGE as wParam and 0 as lParam (again, as 
this is a must for this message).


Regards,


-- 
Michał Jazłowiecki (michalj)
Psi Forum & Wiki Moderator



More information about the psi-devel mailing list