views:

1538

answers:

1

Has anyone successfully trapped the power/standby button on a WM5 device such that your code prevented users "switching off" even the screen?

I have an application that uses the screen in a landscape orientation and I'd like to trap the power key press so that (a) users can hold the device with both hands and not accidentally power-down the screen and (as a bonus - b) use it as a UI button.

Perhaps someone has a low level hack? I'm using WM5 as delivered on iPaq RX1950(s).

Remember, there is no such thing as impossible - especially with WM5. If I answer it myself in the meantime, I'll update the question.


Update!

I discovered three tricks that work, in reverse order of usability:

  1. Patch keybddr.dll (on this device), re-inject into the ROM via your favourite means. On this device with this factory ROM - it works, but I didn't want to permanently disable it.

  2. Sync to the Power Management message queue and turn the device "on" whenever it says it's going down.

  3. Change the "Power States" in the registry so they're all (most of them) "on". This way, I can use RAPI to disable the power button and have the software on the device "reset" the registry on event x, y and z.

+2  A: 

The implementation of the power button is OEM dependent, so a solution on one device is not likely to work on another device. Because of the wide variance of implementations in Windows Mobile devices you'll find this is true with many low level features.

The alternative involves a combination of things

  • Run your application in unattended mode
  • Monitor for power change events
  • when the device changes to unattended mode request full on mode

A full discussion of power management is beyond what I can discuss here. You can read more about it here: http://www.codeproject.com/KB/mobile/WiMoPower1.aspx

There's also a sample that shows how one can register for power events here: http://www.codeproject.com/KB/mobile/WiMoQueue.aspx

Joel
Thanks Joel.The second link enabled one method of disabling it!
Ben