コード例 #1
0
ファイル: TestPMForm1.cs プロジェクト: shahbazp12/Samples
        private void InitializePowerManager()
        {
            // Create a new instance of the PowerManager class
            pwrMngr = new PowerManager();

            // Hook up the Power notify event. This event would not be activated
            // until EnableNotifications is called.
            pwrMngr.PowerNotify += new PowerManager.PowerEventHandler(OnPowerNotify);

            // Enable power notifications. This will cause a thread to start
            // that will fire the PowerNotify event when any power notification
            // is received.
            pwrMngr.EnableNotifications();

            //// Get the current power state.
            //StringBuilder systemStateName = new StringBuilder(20);
            //PowerManager.SystemPowerStates systemState;
            //int nError = pwrMngr.GetSystemPowerState(systemStateName, out systemState);
        }