Connected standby notification for a W8 Service(W8 服务的连接待机通知)
问题描述
我有一个服务,用 C++ 开发,在 Windows 8(和 8.1)上运行.怎样才能知道系统已经进入连接待机?
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?
由于这是一项服务,它没有窗口,我应该使用 PowerRegisterSuspendResumeNotification,但它似乎不起作用.有谁知道我怎么能收到这样的通知?
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?
推荐答案
我已经联系了 Microsoft 的技术支持.这是他们的回答:
I have contacted Microsoft's technical support. This is their answer:
对于 ConnectedStandby 进入/退出没有直接通知,但您可以只使用监视器开/关通知,因为 ConnectedStandby 与支持 AOAC 的系统上的屏幕关闭同义(但不是在旧系统上,AOAC 功能可以通过使用 CallNtPowerInformation 获取 SystemPowerCapabilities 并查看 SYSTEM_POWER_CAPABILITIES 结构的 AoAc 值而获得).
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).
要获取显示器开/关通知,您可以使用 RegisterPowerSettingNotification 并使用 GUID_MONITOR_POWER_ON 电源设置 GUID.
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.
这篇关于W8 服务的连接待机通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:W8 服务的连接待机通知
基础教程推荐
- CString 到 char* 2021-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 初始化列表*参数*评估顺序 2021-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
