如何在Windows Mobile上运行代码,同时暂停? [英] How can I run code on Windows Mobile while being suspended?

查看:130
本文介绍了如何在Windows Mobile上运行代码,同时暂停?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Windows Mobile PocketPC(或似乎)被暂停时运行一些C ++代码。我的意思是一个例子是HTC Home插件,显示(其中)一个选项卡,其中HTC音频管理器可以用于播放mp3文件。当我按下开/关按钮时,显示屏变黑,但音频继续播放。

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.

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

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.

我猜想一些低级的API魔术这个工作,或者代码在一些中断级别播放音频播放,或者设备进入不同的挂起模式。

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.

推荐答案

xda开发人员论坛,说明操作方法,它作为思想工作。要点是:

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


  • 将设备设置为在进入无人参与模式时发送通知。 PowerPolicyNotify(PPN_UNATTENDEDMODE,TRUE)

  • 对于无人值守模式下需要的每个设备,请调用 SetPowerRequirement(Lgpd0:,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(),告诉设备不要关闭< 模式,使用 ReleasePowerRequirement()释放任何设备,并使用 StopPowerNotifications()停止接收电力通知。

  • 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().

这篇关于如何在Windows Mobile上运行代码,同时暂停?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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