我如何拦截在Windows物理电源按钮的推动? [英] How can I intercept the push of the physical power button in Windows?

查看:184
本文介绍了我如何拦截在Windows物理电源按钮的推动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法拦截pssed为了响应该事件的物理电源按钮时$ P $的事件?即:

Is there any way to intercept the event of the physical power button being pressed in order to react to this event? i.e.:

Push button -> My program catches the event -> My program performs action.

我的目标是写一个C#程序/服务,将监听电源按钮事件,然后在打开的向我该怎么办关机对话框(就像它早在Windows XP中的天数)。

My goal is to write a C# program/service that will listen for the power button event and then open the "Ask me what to do" shutdown dialog (Like it did back in the days of Windows XP).

推荐答案

我可以解释给你的理论:该按钮(这是一个的绑关机在大多数系统上的一个按钮)已根据电源选项选项,在这里你可以specificy采取的措施时,电源按钮是pressed ...

I can explain it to you in theory: The button (it's a button that's tied to shutdown on most systems) has an option under "power options", where you can specificy the action to take when the power button is pressed...

这是你要找的这一行动赛事的通过窗户,然后实例关闭事件绑定按钮。有这么剖析和监视Windows变量和调用的程序,你必须使用其中的一个数字出来和拦截/覆盖它。

It's that ACTION event you're looking for that's bound to the button by windows that THEN instantiates the shutdown event. There's programs that dissect and monitor windows variables and calls, you'd have to use one of those to figure it out and intercept/override it.

这篇关于我如何拦截在Windows物理电源按钮的推动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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