示例#1
0
        public static PowerType?GetPowerType()
        {
            var powerState = new SYSTEM_POWER_STATUS();

            if (!PlatformInvokeKernel32.GetSystemPowerStatusRef(powerState))
            {
                Log.Warning("Unable to get power state");
                return(null);
            }

            return(powerState.ACLineStatus == ACLineStatus.Online ? PowerType.AC : PowerType.DC);
        }
示例#2
0
 public static extern bool GetSystemPowerStatusRef(SYSTEM_POWER_STATUS sps);