I'm not sure if I'm reading documentation correctly, so I'd appreciate if someone could clarify.
I run the following API to put Windows XP SP3 into sleep (or standby mode) from a worker thread:
Then in the main thread, while processing window messages:Code:BOOL bForced = TRUE; SetSuspendState(FALSE, bForced, FALSE);
So when SetSuspendState is called with request for a 'forced' sleep mode, the PBT_APMSUSPEND notification is never broadcast. Only if I set forced parameter to FALSE I receive it.Code:LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { if(message == WM_POWERBROADCAST) { if(wParam == PBT_APMSUSPEND) { AddLogMsg(_T("SUSPEND event received")); } else if(wParam == PBT_APMRESUMEAUTOMATIC) { AddLogMsg(_T("RESUME event received")); } } //Do other processing }
Any idea why?
PS. PBT_APMRESUMEAUTOMATIC is received in either case.
PS2. PBT_APMSUSPEND is always received when run on Windows Vista/7.




Reply With Quote