简体   繁体   中英

Detect soft reset on Windows Mobile device

Is there a way to make my Windows Mobile 6.1 application react to system reset? If it matters, I am using 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). During the reset, the PM broadcasts a power manegment notification which you can requent to receive by calling the RequestPowerNotifications APIs. One of the last things the power manager does is goes single-threaded and calls all drivers' Xxx_PowerDown methods. 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. Be aware that the PM broadcasts the notification and just keeps on moving. It does not wait for anyone to complete any activity (like it does in calling 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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