Connected standby notification for a W8 Service

我的梦境 提交于 2019-11-30 09:11:55

I have contacted Microsoft's technical support. This is their answer:

There are no direct notifications for ConnectedStandby enter/exit, but you can just use the monitor on/off notifications since ConnectedStandby is synonymous with screen off on an AOAC capable system (but is not on a legacy system, AOAC capability can be had by getting SystemPowerCapabilities using CallNtPowerInformation and looking at the AoAc value of the SYSTEM_POWER_CAPABILITIES struct).

To get monitor on/off notifications you can use RegisterPowerSettingNotification and use the GUID_MONITOR_POWER_ON power setting GUID.

Looks like there is only a workaround for this by listening to screen on/off events.

This is excruciating unable to comment!!

CallNtPowerInformation(SystemPowerCapabilities, ...) will return SYSTEM_POWER_CAPABILITIES. It has an BOOLEAN member AoAc, if it is FALSE, your system does not support connected standby.

It worked for me on an Intel custom hardware(same as machines in market). AoAc = Always On Always Connected, Intel's preference.

Couldn't find any offical solution of this to date. In my case detecting SessionSwitch with lock/unlock reasons was a good enough supplement:

SystemEvents.SessionSwitch += SystemEvents_SessionSwitch;

...

private void SystemEvents_SessionSwitch(object sender, SessionSwitchEventArgs e)
    {
        switch (e.Reason)
        {
            case SessionSwitchReason.SessionLock:
                // Going into lock/standby screen
                break;
            case SessionSwitchReason.SessionUnlock:
                // Back from lock/standby
                break;
            default:
                break;
        }
    }

I was not allowed to comment, surprise am allowed to provide answer. This not answer definitely, but discussion.

Do you not receive notification for PBT_APMSUSPEND, PBT_APMRESUMESUSPEND and PBT_APMRESUMEAUTOMATIC in you callback?

After going through http://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/26629db2-6d33-427c-a767-8c857d775079/windows-8-connected-standby-and-aoac?forum=wdk

it appears, applications need not differentiate between S3 and CS mode(a.k.a AOAC, always on, always connected.). Though it is not clear if network activity is allowed in CS.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!