Пример #1
0
        public static SYSTEM_POWER_STATUS_EX2 GetSystemPowerStatus()
        {
            var retVal = new SYSTEM_POWER_STATUS_EX2();

            GetSystemPowerStatusEx2(retVal, Marshal.SizeOf(retVal), 1);
            return(retVal);
        }
Пример #2
0
        /// <summary>
        /// Wrapper over GetSystemPowerStatusEx2
        /// </summary>
        /// <returns></returns>
        public static int GetBatteryLifePercent2()
        {
            SYSTEM_POWER_STATUS_EX2 status2 = new SYSTEM_POWER_STATUS_EX2();

            int percent = 0;

            if (GetSystemPowerStatusEx2(status2,
                                        (uint)Marshal.SizeOf(status2), false) ==
                (uint)Marshal.SizeOf(status2))
            {
                percent = status2.BackupBatteryLifePercent;
            }
            return(percent);
        }
Пример #3
0
 public static extern uint GetSystemPowerStatusEx2(SYSTEM_POWER_STATUS_EX2 lpSystemPowerStatus,
                                                   uint dwLen, bool fUpdate);
Пример #4
0
 public static extern int GetSystemPowerStatusEx2(
     SYSTEM_POWER_STATUS_EX2 statusInfo,
     int length,
     int getLatest
     );