示例#1
0
        static string GetPowerInfo()
        {
            StringBuilder       info  = new StringBuilder();
            SYSTEM_POWER_STATUS power = new SYSTEM_POWER_STATUS();

            GetSystemPowerStatus(ref power);
            info.AppendLine("Power");
            info.AppendLine("\tAC power status : " + power.ACLineStatus);
            info.AppendLine("\tBattery charge status : " + power.BatteryFlag);
            if (power.BatteryFlag == BatteryFlag.NoSystemBattery)
            {
                return(info.ToString());
            }
            info.AppendLine("\tBattery charge remaining : " + power.BatteryLifePercent + "%");
            if (power.BatteryLifeTime != -1)
            {
                info.AppendLine("\tBattery life time remaining : " + power.BatteryLifeTime / 60 + " min");
            }
            if (power.BatteryFullLifeTime != -1)
            {
                info.AppendLine("\tFull battery life time : " + power.BatteryFullLifeTime / 60 + " min");
            }
            return(info.ToString());
        }
示例#2
0
 internal static extern bool GetSystemPowerStatus(ref SYSTEM_POWER_STATUS powerStatus);