如何检测,当笔记本电脑的电源线没有连接? [英] How to detect when laptop power cable has been disconnected?

查看:663
本文介绍了如何检测,当笔记本电脑的电源线没有连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

OK,做它。无数次我的笔记本电脑只是关闭了我的比赛中间,因为我的电源线没有我注意到,它已断开连接。

OK that does it. For the umpteenth time my laptop just shut down in the middle of my game because my power cable had disconnected without me noticing it.

现在我想要写一个小C#程序,检测时,我的电源线断开,然后发出一个不错的长期系统提示音。我可以使用什么API?

Now I want to write a little C# program that detects when my power cable disconnects and then emits a nice long System beep. What API could I use for that?

推荐答案

这应该是微不足道的实施使用<一个href="http://msdn.microsoft.com/en-us/library/system.windows.forms.systeminformation.powerstatus.aspx">SystemInformation.PowerStatus属性。并且,即使生活在Windows.Forms的,应该是从一个系统服务完全可用

This should be trivial to implement using the SystemInformation.PowerStatus property. And even though that lives in Windows.Forms, it should be perfectly usable from a system service.

对于一个解决方案,也适用于Compact Framework的,请参见 HOWTO:获取设备电源状态

For a solution that also works on the Compact Framework, see HOWTO: Get the Device Power Status

这篇关于如何检测,当笔记本电脑的电源线没有连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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