简体   繁体   English

在Windows Mobile设备上检测软重置

[英]Detect soft reset on Windows Mobile device

Is there a way to make my Windows Mobile 6.1 application react to system reset? 有没有办法让我的Windows Mobile 6.1应用程序对系统重置做出反应? If it matters, I am using Compact Framework 3.5. 如果重要的话,我正在使用Compact Framework 3.5。

A system reset (ie a call to the kernel with IOCTL_HAL_REBOOT) goes through the power manager (well it should, the OEM might have opted otherwise but that would be rare). 系统重置(即使用IOCTL_HAL_REBOOT调用内核)通过了电源管理器(当然,OEM可能选择了其他方法,但这很少见)。 During the reset, the PM broadcasts a power manegment notification which you can requent to receive by calling the RequestPowerNotifications APIs. 在重置期间,PM广播电源管理通知,您可以通过调用RequestPowerNotifications API来经常接收该通知。 One of the last things the power manager does is goes single-threaded and calls all drivers' Xxx_PowerDown methods. 电源管理器要做的最后一件事是进入单线程并调用所有驱动程序的Xxx_PowerDown方法。 The drivers at this point have the option of doing clean up, final flushing, etc. to get into a stable state and then the device restarts. 此时, 驱动程序可以选择进行清理,最终冲洗等操作,以进入稳定状态,然后重新启动设备。

From an app perspective, the RequestPowerNotifications call is the only thing you can do. 从应用程序的角度来看,RequestPowerNotifications调用是您唯一可以做的事情。 Be aware that the PM broadcasts the notification and just keeps on moving. 请注意,PM会广播通知,并且会继续前进。 It does not wait for anyone to complete any activity (like it does in calling Xxx_PowerDown). 不会等待任何人来完成的任何活动(如它在呼唤Xxx_PowerDown一样)。 This often means that your application will never get the notification, or if it does you may only get the opportunity to run a couple lines of code (I think the most I've seen was about 4 lines). 这通常意味着您的应用程序将永远不会收到通知,否则,您可能只有机会运行几行代码(我想我所看到的最多是四行代码)。 On a suspend/resume, the app code typically runs after you wake back up. 在挂起/恢复上,应用代码通常在您唤醒后运行。 With a reset, since RAM and processor are reset, you don't get that opportunity. 重置后,由于RAM和处理器被重置,因此您没有机会。

So, after that long-winded response, the short answer is that you might be able to get the notification, but even if you do it's unlikely you'll actually be able to do anything in response to it. 因此,在经过漫长的响应之后,简短的答案是您可能能够收到通知,但是即使您这样做了,您也不大可能实际上能够对此做出响应。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM