How can I intercept the push of the physical power button in Windows?

梦想与她 提交于 2019-11-30 21:23:02

You could use SystemEvents.SessionEnding Event

However I am not sure if this will work if the power button is pressed, this event Occurs when the user is trying to log off or shut down the system.

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...

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.

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