Windows Mobile-電源ボタンを無効にする
-
03-07-2019 - |
質問
WM5デバイスの電源/スタンバイボタンをだれでも正常にトラップして、コードがユーザーの「スイッチオフ」を妨げた。画面でも?
画面を横向きで使用するアプリケーションがあり、(a)ユーザーが誤って画面の電源を切らずにデバイスを両手で持つことができるように、電源キーを押したままにしますボーナス-b)UIボタンとして使用します。
おそらく誰かが低レベルのハッキングをしているのでしょうか? iPaq RX1950で提供されるWM5を使用しています。
覚えておいてください、不可能というものはありません-特にWM5では。その間に自分で答える場合は、質問を更新します。
更新!
ユーザビリティの逆順で機能する3つのトリックを発見しました:
-
keybddr.dll(このデバイス上)にパッチを適用し、お好みの方法でROMに再挿入します。この工場出荷時のROMを搭載したこのデバイスでは動作しますが、永久に無効にしたくありませんでした。
-
電源管理メッセージキューに同期して、デバイスを「オン」にします。それがダウンすると言っているときはいつでも。
-
「電力状態」の変更レジストリにあるため、すべて(ほとんど)が「オン」です。このようにして、RAPIを使用して電源ボタンを無効にし、デバイスにソフトウェアを「リセット」することができます。イベントx、y、zのレジストリ。
解決
電源ボタンの実装はOEMに依存するため、あるデバイスでのソリューションは別のデバイスでは機能しない可能性があります。 Windows Mobileデバイスの実装にはさまざまなバリエーションがあるため、これは多くの低レベル機能に当てはまります。
代替には、物事の組み合わせが含まれます
- アプリケーションを無人モードで実行します
- 電源変更イベントの監視
- デバイスが無人モードに変更された場合、フルオンモードリクエスト
電源管理の完全な議論は、ここで議論できることを超えています。詳細については、こちらをご覧ください。 http://www.codeproject.com/KB/mobile/WiMoPower1.aspx
ここで、電源イベントに登録する方法を示すサンプルもあります。 http://www.codeproject.com/KB/mobile/WiMoQueue.aspx
他のヒント
次のコードは電源ボタンを無効にしませんが、デバイスがオフになっている場合、10秒以内にデバイスを再びオンにします。また、省電力機能も無効になります。
using System;
using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.Text;
namespace Core.Mobile
{
/// <summary>
/// Allows manipulation the power management i.e. system standby
/// </summary>
public static class PowerManipulation
{
#region Private variables
private static System.Threading.Timer _timer = null;
private const int INTERVAL = 10000; //10 seconds
#endregion
#region Public methods
/// <summary>
/// Prevents the application from suspending/sleeping
/// </summary>
public static void DisableSleep()
{
if (_timer == null)
{
_timer = new System.Threading.Timer(new System.Threading.TimerCallback(Timer_Tick), null, 0, INTERVAL);
}
try
{
PowerPolicyNotify(PPN_UNATTENDEDMODE, 1); //Ensure the application still runs in suspend mode
}
catch { }
}
/// <summary>
/// Allows suspend/sleep operations
/// </summary>
public static void EnableSleep()
{
if (_timer != null)
{
_timer.Dispose();
_timer = null;
}
try
{
PowerPolicyNotify(PPN_UNATTENDEDMODE, 0);
}
catch { }
}
#endregion
#region Private methods
/// <summary>
/// Internal timer for preventing standby
/// </summary>
private static void Timer_Tick(object state)
{
try
{
SystemIdleTimerReset();
SetSystemPowerState(null, POWER_STATE_ON, POWER_FORCE);
}
catch { }
}
#endregion
#region PInvoke
private const int PPN_UNATTENDEDMODE = 0x00000003;
private const int POWER_STATE_ON = 0x00010000;
private const int POWER_STATE_OFF = 0x00020000;
private const int POWER_STATE_SUSPEND = 0x00200000;
private const int POWER_FORCE = 4096;
private const int POWER_STATE_RESET = 0x00800000;
/// <summary>
/// This function resets a system timer that controls whether or not the
/// device will automatically go into a suspended state.
/// </summary>
[DllImport("CoreDll.dll")]
private static extern void SystemIdleTimerReset();
/// <summary>
/// This function resets a system timer that controls whether or not the
/// device will automatically go into a suspended state.
/// </summary>
[DllImport("CoreDll.dll")]
private static extern void SHIdleTimerReset();
/// <summary>
/// This function allows the current power state to be manipulated, i.e. turn the device on
/// </summary>
[DllImport("coredll.dll", SetLastError = true)]
static extern int SetSystemPowerState(string psState, int StateFlags, int Options);
/// <summary>
/// This function sets any power notification options
/// </summary>
[DllImport("CoreDll.dll")]
static extern bool PowerPolicyNotify(int dwMessage, int onOrOff);
#endregion
}
}