سؤال

وقد أي شخص بنجاح المحاصرين السلطة/الاستعداد زر على WM5 الجهاز الخاص بك كود منع المستخدمين "إطفاء" حتى الشاشة ؟

يجب تطبيق يستخدم الشاشة في اتجاه أفقي و أود أن فخ السلطة الرئيسية اضغط بحيث (a) يمكن للمستخدمين عقد الجهاز بكلتا يديه و لا عن طريق الخطأ السلطة إلى أسفل الشاشة (على سبيل المكافأة - ب) استخدامه بمثابة واجهة المستخدم زر.

ربما شخص ما لديه انخفاض مستوى الإختراق ؟ أنا باستخدام WM5 كما سلمت على الكف RX1950(s).

تذكر هناك لا يوجد شيء اسمه مستحيل خصوصا مع WM5.إذا أجبت بنفسي في هذه الأثناء, سوف أقوم بتحديث هذا السؤال.


تحديث!

اكتشفت ثلاثة الحيل التي تعمل في ترتيب عكسي من الاستخدام:

  1. التصحيح keybddr.dll (على هذا الجهاز) وإعادة حقن في ROM عن طريق المفضلة يعني.على هذا الجهاز مع هذا المصنع ROM - يعمل, ولكن لم أكن أريد أن تعطيل دائم عليه.

  2. مزامنة إلى إدارة الطاقة انتظار الرسائل وتشغيل الجهاز "على" عندما يقول إنه ذاهب إلى أسفل.

  3. تغيير "الطاقة" في التسجيل حتى أنهم جميعا (معظمهم) "على".بهذه الطريقة يمكنني استخدام رابي إلى تعطيل زر الطاقة لديك برنامج على الجهاز "إعادة تعيين" التسجيل في الحدث x ، y و z.

هل كانت مفيدة؟

المحلول

تنفيذ زر الطاقة هو OEM تعتمد لذا الحل على جهاز واحد ليس من المرجح أن تعمل على جهاز آخر.بسبب تباين واسع من التطبيقات في أجهزة ويندوز موبايل ستجد هذا صحيح مع العديد من تدني مستوى الميزات.

بديل ينطوي على مزيج من الأشياء

  • تشغيل التطبيق الخاص بك في وضع غير المراقب
  • رصد قوة تغيير الأحداث
  • عندما يكون الجهاز تغييرات في وضع غير المراقب طلب الكاملة على الوضع

مناقشة كاملة من إدارة الطاقة هو أبعد ما يمكن أن نناقش هنا.يمكنك قراءة المزيد عن ذلك هنا: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