如何使用ACPI函数设置ACLineStatus
本文关键字:设置 ACLineStatus 函数 ACPI 何使用 | 更新日期: 2023-09-27 18:05:46
我想读取BatteryLifePercent的值,如果它高于80%(0.80),则将ACLineStatus设置为离线。
我试过使用
[DllImport("kernel32.dll", SetLastError = true)]
private static extern Boolean GetSystemPowerStatus(out SystemPowerStatus sps);
private enum ACLineStatus : byte
{
Offline = 0,
Online = 1,
Unknown = 255
}
private enum BatteryFlag : byte
{
High = 1,
Low = 2,
Critical = 4,
Charging = 8,
NoSystemBattery = 128,
Unknown = 255
}
private struct SystemPowerStatus
{
public ACLineStatus LineStatus;
public BatteryFlag flgBattery;
public Byte BatteryLifePercent;
public Byte Reserved1;
public Int32 BatteryLifeTime;
public Int32 BatteryFullLifeTime;
}
public static Boolean ACPowerPluggedIn()
{
SystemPowerStatus SPS = new SystemPowerStatus();
GetSystemPowerStatus(out SPS);
if (SPS.LineStatus == ACLineStatus.Online)
{
return true;
}
else
{
return false;
}
}
public static Int32 BatteryCharge()
{
SystemPowerStatus SPS = new SystemPowerStatus();
GetSystemPowerStatus(out SPS);
return (Int32)SPS.BatteryLifePercent;
}
可以用来读取BatteryLifePercent。但是我不知道如何将ACLineStatus设置为离线以避免进一步收费。
我也想知道,是否可以使用acpi控制方法(http://msdn.microsoft.com/en-us/library/windows/hardware/ff536139(v=vs.85).aspx)?
ACPI方法只能从内核驱动程序调用,然后只能方法中声明该方法的设备的驱动程序堆栈DSDT .