标签:style blog color line new div
[DllImport("kernel32.dll",EntryPoint="GetSystemPowerStatus")] //win32 api private static extern void GetSystemPowerStatus(ref SYSTEM_POWER_STATUS lpSystemPowerStatus); public struct SYSTEM_POWER_STATUS //结构体 { public Byte ACLineStatus; //0 = offline, 1 = Online, 255 = UnKnown Status. public Byte BatteryFlag; public Byte BatteryLifePercent; public Byte Reserved1; public int BatteryLifeTime; public int BatteryFullLifeTime; } /// <summary> /// 获取系统电量百分比 /// </summary> /// <returns></returns> public static float GetSystemPower() { SYSTEM_POWER_STATUS SysPower = new SYSTEM_POWER_STATUS(); GetSystemPowerStatus(ref SysPower); return SysPower.BatteryLifePercent; }
标签:style blog color line new div
原文地址:http://www.cnblogs.com/denghejun/p/3817041.html