检查 Windows Mobile 设备是否空闲
我有一个 Windows Mobile 5 程序(紧凑框架 3.5),我需要能够检测设备何时处于空闲状态。
现在我只是检查背光是否关闭。像这样:
[DllImport("coredll.dll", EntryPoint = "sleep", SetLastError = true)]
internal static extern void sleep(int dwMilliseconds);
....
//Get the current power state of the system
int winError = CoreDLL.GetSystemPowerState(systemStateName, out systemPowerStates);
if (winError == 0)
{
//If the backlight is off, consider the state to be idle.
if (systemStateName.ToString() == "backlightoff")
{
idle = true;
}
}
我认为这可能已经接近了,但我想知道该设备是否真的没有被使用。
I have a windows mobile 5 program (compact framework 3.5) that I need to be able to detect when the device is idle.
Right now I am just checking to see if the backlight is off. Like this:
[DllImport("coredll.dll", EntryPoint = "sleep", SetLastError = true)]
internal static extern void sleep(int dwMilliseconds);
....
//Get the current power state of the system
int winError = CoreDLL.GetSystemPowerState(systemStateName, out systemPowerStates);
if (winError == 0)
{
//If the backlight is off, consider the state to be idle.
if (systemStateName.ToString() == "backlightoff")
{
idle = true;
}
}
I think this may be getting close, but I would like to know if the device is truly not being used.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您使用的是正确的函数,只需检查状态(按位标志):
使用
POWER_STATE_IDLE = 0x00100000
。编辑:要回答您的评论,请查看 RequestPowerNotification 函数。当电源状态更改时,您将收到 POWER_BROADCAST 消息。
You're using the right function, simply check for the states (which are bitwise flags):
with
POWER_STATE_IDLE = 0x00100000
.Edit: to answer your comment, look at the RequestPowerNotification function. You'll receive POWER_BROADCAST message when the power state changes.