⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 powerstate.cs

📁 wince power manager source code
💻 CS
字号:
using System;
using System.Runtime.InteropServices;


namespace Power
{
	/// <summary>
	/// Summary description for PowerState.
	/// </summary>
	public class PowerStatus
	{
		public enum _ACLineStatus : byte 
		{
			Offline = 0, 
			Online = 1, 
			Unknown = 255
		}
		public enum _BatteryFlag : byte 
		{
			High = 0x01, 
			Low = 0x02, 
			Critical = 0x04, 
			Charging = 0x08,
			NoSystemBattery = 0x80, 
			Unknown = 0xFF
		}

		internal struct SystemPowerStatus 
		{
			public _ACLineStatus ACLineStatus;
			public _BatteryFlag  BatteryFlag;
			public byte          BatteryLifePercent;
			public byte          Reserved1;
			public uint          BatteryLifeTime;
			public uint          BatteryFullLifeTime;
		}
    
		[DllImport("kernel32")]
		private static extern
			bool GetSystemPowerStatus (out SystemPowerStatus sps);

		private SystemPowerStatus _sps = new SystemPowerStatus();

		public PowerStatus()
		{
			//Initialise the powerstate
			GetSystemPowerStatus(out _sps);
		}

		public _ACLineStatus ACLineStatus
		{
			get { return _sps.ACLineStatus; }
		}
		public _BatteryFlag  BatteryFlag
		{
			get { return _sps.BatteryFlag; }
		}
		public byte          BatteryLifePercent
		{
			get { return _sps.BatteryLifePercent; }
		}
		public uint          BatteryLifeTime
		{
			get { return _sps.BatteryLifeTime; }
		}
		public uint          BatteryFullLifeTime
		{
			get { return _sps.BatteryFullLifeTime; }
		}

	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -