防止 Pocket PC 设备在断电时关闭应用程序
如何防止袖珍 PC 设备在按下电源按钮时从我的应用程序关闭? 我正在使用 C#。
How can I prevent the pocket PC device from shutting down from my application when the power button pressed? I am using C#.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 Microsoft.WindowsCE.Form.MessageWindows 类来拦截电源按钮事件。 该解决方案不可移植,因为不同机器上的硬件密钥会有所不同。
不过,我建议您不要完全禁用电源。 看看我在另一个问题中的回答 此处。 您还可以使用 openetcf 轻松创建断电事件处理程序并注册唤醒事件。 您应该根据您想要实现的目标来实现应用程序逻辑,例如每隔一分钟唤醒一次以运行一个进程。
You could use the Microsoft.WindowsCE.Form.MessageWindows class to intercept the Power Button event. This solution will not be portable, as the hardware key will be different in different machines.
I recommend however that you don't disable power down completely. Have a look at my answer in another question here. You could also use openetcf to easily create power down events handlers and register wake up events. You should implement the application logic based on what you are trying to achieve, for instance wake up every one minute to run a process.
您可以尝试更改设备“BLK1:”(黑光设备)的电源要求。 请注意,所有设备和操作系统版本或供应商特定扩展上的行为可能有所不同。
为此,您可以编写类似 : 的内容
并这样称呼它 :
但这通常不是一个好的做法,让设备长时间打开背光可能会大大降低其自主性。
You can try changing the power requirements for the device "BLK1:", which is the blacklight device. Be aware that the behavior may not be the same on all devices and version of the OS or Vendor specific Extensions.
To do this, you can write something like :
and call it this way :
But this is generally not a good practice, leaving a device with the backlight on for extended periods might reduce dramatically its autonomy.