Connected standby notification for a W8 Service
Asked Answered
D

4

10

I have a service, developed in C++ running on Windows 8 (and 8.1). How can I get to know that the system has entered Connected Standby?

Since this is a service, it does not have a window, I should be using PowerRegisterSuspendResumeNotification, but it does not seem to be working. Does anyone know how I can get such a notification?

Disseminate answered 21/11, 2013 at 11:6 Comment(1)
Same problem - no notifications when system enters connected standby. I get notifications allright when the system hibernates, though.Meador
D
7

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.

Disseminate answered 19/3, 2014 at 14:36 Comment(1)
For additional reference, there's a later SDK blog giving the same answer as the tech support response: How to get notified when going in and out of connected standby from a Windows Service?, i.e. RegisterPowerSettingNotification using GUID_MONITOR_POWER_ONFogbound
M
4

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;
        }
    }
Mcallister answered 14/4, 2019 at 14:10 Comment(0)
H
2

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.

Homesteader answered 20/2, 2014 at 17:12 Comment(2)
As @Chandrayya commented on your other answer, you need some minimum reputation in order to comment.Meador
This method has returned me many false negatives, I wouldn't count on using it.Inquire
H
0

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.

Homesteader answered 17/2, 2014 at 4:59 Comment(3)
You can able to comment once you get gained required reputations.Regenerate
The callback is not called at all when the system goes to or comes from connected standby. The callback IS called with regular standby/resume.Meador
exactly my observation.Homesteader

© 2022 - 2024 — McMap. All rights reserved.