有没有人成功地被困在电力/备用按钮在WM5设备这样的,你的代码防止用户"关闭"甚至在屏幕上?

我有一个应用程序使用屏幕中的一个横向和我想陷阱的动力的关键的新闻,以便(a)用户可以保持装置用两只手,不小心掉电视和(作为奖励b)使用它作为一个UI按钮。

也许有人低水平的黑客?我使用的WM5作为交付iPaq RX1950(s)。

请记住,有的是 没有这样的事情不可能的 -特别是与WM5.如果我回答了它自己与此同时,我会更新的问题。


更新!

我发现了三个技巧的工作,相反的顺序的可用性:

  1. 补丁keybddr.dll (在这种装置),重新注入ROM通过你最喜欢的手段。在这种装置与该工厂ROM-它的工作原理,但我不想永久禁止。

  2. 同步电管理信息队和转的设备的"开",每当它说,它的下降。

  3. 改变"功率国家"的注册表,以便他们所有的(他们中的大多数)"上"。这样,我可以使用RAPI禁用和具有的软件设备上的"重启"的注册表上的事件的x、y和z。

有帮助吗?

解决方案

执行电按钮是OEM依赖,这样一个解决方案上的一个设备是不是有可能的工作上另一个装置。因为广泛的差异,实现在Windows移动设备的你会发现这是真的许多低级别的特点。

替代涉及一个事物的组合

  • 运行应用程序在无人参与模式
  • 监视器功率变化事件
  • 当设备的改变人参与的模式的请求完整的模式

充分讨论的电力管理超出了什么我可以在此讨论。你可以读取更多关于它在这里: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
    }
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top