在 Windows 中捕获笔记本电脑盖关闭事件? [英] Capturing laptop lid closing event in windows?

查看:28
本文介绍了在 Windows 中捕获笔记本电脑盖关闭事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方法来拦截笔记本电脑盖关闭事件.在 Windows 7 中,电源管理允许我在盖子关闭时选择所需的行为.所以一定有办法让窗户知道盖子什么时候合上.

I am looking for a way to intercept the laptop lid closing event. In windows 7, the power management allows me to select a desired behavior when the lid is closed. So there must be a way windows knows when the lid is closed.

我进行了研究,但只找到了监测睡眠事件的建议.我想更具体地只响应盖子关闭.

I did my research, but only found suggestions to monitor the sleep event. I would like to be more specific to only respond to lid closing.

有人有什么建议吗?

谢谢!

推荐答案

您可以使用 RegisterPowerSettingNotification 注册关闭盖子时的通知.

You can register for notification when the lid is shut with RegisterPowerSettingNotification.

AnswerLid 关闭操作更改通知

http:///social.msdn.microsoft.com/Forums/en-US/tabletandtouch/thread/0bbf90be-9322-47fb-bfa4-016b57211b3a

在 Vista 中,您可以注册盖子关闭操作更改时的回调.这是通过调用 RegisterPowerSettingNotification 完成的(参见 http://msdn2.microsoft.com/en-us/library/aa373196.aspx 了解详情).您感兴趣的此电源设置的 GUID 是 GUID_LIDCLOSE_ACTION.这在 Platform SDK 的 wdm.h 中定义.

In Vista you can register for a callback for when the Lid Close Action changes. This is done by calling RegisterPowerSettingNotification (see http://msdn2.microsoft.com/en-us/library/aa373196.aspx for details). The GUID for this power setting you're interested in is GUID_LIDCLOSE_ACTION. This is defined in wdm.h in the Platform SDK.

一旦注册,WM_POWERBROADCAST 将发送到您的应用程序,并将 wParam 设置为 PBT_POWERSETTINGCHANGE.每当盖子关闭操作的值发生变化时,就会发送此事件.lParam 包含一个指向 POWERBROADCAST_SETTING 结构的指针(参见 http://msdn2.microsoft.com/en-us/library/aa372723.aspx) 包含有关设置更改的信息.

Once registered, a WM_POWERBROADCAST will be sent to your application with wParam set to PBT_POWERSETTINGCHANGE. This event is sent anytime the value for the lid close action changes. The lParam contains a pointer to a POWERBROADCAST_SETTING structure (see http://msdn2.microsoft.com/en-us/library/aa372723.aspx) containing information on the setting change.

这篇关于在 Windows 中捕获笔记本电脑盖关闭事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆