如何在 Windows Mobile 暂停时运行代码?

发布于 2024-07-09 21:26:24 字数 357 浏览 7 评论 0原文

我想在 Windows Mobile PocketPC 正在(或似乎)被暂停时运行一些 C++ 代码。 我指的一个例子是 HTC Home 插件,它显示(除其他外)一个选项卡,其中 HTC 音频管理器可用于播放 mp3 文件。 当我按下开/关按钮时,显示屏变黑,但音频继续播放。 正如预期的那样,唯一重新打开的按钮是开/关按钮。

到目前为止,我尝试的是捕获硬件按钮按下(有效)并关闭视频显示(有效)。 这种方法不起作用的是,当(意外地)按下设备上的任意键时,视频显示就会打开。 我认为这不是 HTC 音频管理器中采用的方法。

我猜测需要一些低级 API 魔法才能实现此功能,或者播放音频的代码在某个中断级别运行,或者设备进入不同的挂起模式。

I'd like to run some C++ code while the Windows Mobile PocketPC is (or seems) being suspended. An example what I mean is the HTC Home plugin that shows (among others) a tab where the HTC Audio Manager can be used to play back mp3 files. When I press the on/off button, the display goes black, but the audio keeps playing. The only button to switch back on is the on/off button, as expected.

What I tried so far is to capture hardware button presses (works) and switch off the video display (works). What doesn't work with this approach is that when (accidentally) pressing any key on the device, the video display is switched on. I think this isn't the approach taken in the HTC Audio Manager.

I'm guessing on some low-level API magic for this to work, or that the code to play back audio runs at some interrupt level, or the device goes into a different suspend mode.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

憧憬巴黎街头的黎明 2024-07-16 21:26:26

首先看一下博客条目为了了解各种电源状态。 您基本上需要的是强制 ScreenOff 状态。 看一下 SetSystemPowerState 函数。

At first have a look at this blog entry in order to understand the various power states. What you basically need is to force the ScreenOff state. Have a look at the SetSystemPowerState function.

土豪 2024-07-16 21:26:25

我在 xda-developers 论坛 上找到了源代码解释了要做什么,并且它按照想法运作。 要点是:

  • 设置设备在进入“无人值守”模式时发送通知。 这是通过 PowerPolicyNotify(PPN_UNATTENDEDMODE, TRUE) 完成的
  • 对于无人值守模式下需要的每个设备,请调用 SetPowerRequirement(L"gpd0:", D0, POWER_NAME|POWER_FORCE, NULL, NULL)< /代码>; “gpd0:”设备是 GPS 中间驱动程序; 使用您需要的任何设备替换或重复呼叫,例如“wav1:”用于音频,“dsk1:”用于存储卡或“com1:”用于串行端口 1.
  • 创建消息队列并使用 RequestPowerNotifications(hMsgQueue) 请求电源通知, PBT_POWERINFOCHANGE | PBT_TRANSITION)
  • 每次发送电源通知时,消息队列都会填充 POWER_BROADCAST 类型的结构。
  • 查找 PBT_TRANSITION 消息类型。 当设备关闭时,例如用户按下关闭按钮,pPwrBrodcast->SystemPowerState 字段将包含一个字符串“无人值守”。
  • 在此转换中,只需调用 SystemIdleTimerReset() 告诉设备不要关闭
  • 当再次发生转换时重复
  • 关闭时,调用 PowerPolicyNotify() 离开无人值守模式,使用 ReleasePowerRequirement() 释放任何设备并使用 StopPowerNotifications() 停止接收电源通知。

I found sourcecode on the xda-developers forum that explains what to do, and it works as thought. The main points are:

  • Set the device to send a notification when going into "unattended" mode. This is done with PowerPolicyNotify(PPN_UNATTENDEDMODE, TRUE)
  • For every device that you need during unattended mode, call SetPowerRequirement(L"gpd0:", D0, POWER_NAME|POWER_FORCE, NULL, NULL); The "gpd0:" device is the GPS Intermediate driver; replace or duplicate call with any device you need, e.g. "wav1:" for audio, "dsk1:" for memory card or "com1:" for serial port 1.
  • Create a message queue and request power notifications using RequestPowerNotifications(hMsgQueue, PBT_POWERINFOCHANGE | PBT_TRANSITION)
  • Every time a power notification is sent, the message queue is filled with a struct of type POWER_BROADCAST.
  • Look for PBT_TRANSITION message type. The field pPwrBrodcast->SystemPowerState then contains a string "unattended" when the device is shut off, e.g. by the user pressing the off button
  • In this transition, just call SystemIdleTimerReset() to tell the device to not shut off
  • Repeat when the transition occurs again
  • When shutting down, call PowerPolicyNotify() to leave unattended mode, release any devices with ReleasePowerRequirement() and stop receiving power notifications with StopPowerNotifications().
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文