private void button3_Click(object sender, EventArgs e) { SystemPowerStatus sps = new SystemPowerStatus(); //SystemPowerStatus sps; GetSystemPowerStatus(ref sps); richTextBox1.AppendText("交流电源状态:" + getACLineStr(sps.ACLineStatus) + "\r\n"); richTextBox1.AppendText("电池充电状态:" + getBatteryFlag(sps.batteryFlag) + "\r\n"); richTextBox1.AppendText("电量百分比:" + sps.batteryLifePercent.ToString() + "\r\n"); richTextBox1.AppendText("秒为单位的电池剩余电量:" + sps.batteryLifeTime.ToString() + "\r\n"); richTextBox1.AppendText("秒为单位的电池充满电的电量:" + sps.batteryFullLifeTime.ToString() + "\r\n"); }
public static extern bool GetSystemPowerStatus(ref SystemPowerStatus systemPowerStatus);