如何得到电池的电量?
下面是三恨大侠给的一段判断系统使用的是外接电源,还是电池的代码,现在我想得到电池的电量,不帮有哪位能提供点帮助,在此十分感谢!!$battery = _BatteryQuery()
Switch $battery
case0
MsgBox(0,0,"AC Power is Offline")
case1
MsgBox(0,0,"AC Power is OnLine")
case Else
MsgBox(0,0,"AC Power is Unknown")
EndSwitch
Func _BatteryQuery()
Local $SystemPower, $ret, $array
; Setup $array and $SystemPower
$SystemPower = DllStructCreate("ubyte;ubyte;ubyte;ubyte;ulong;ulong")
If @error Then
SetError(-1)
Return $array
EndIf
; make the DllCall
$ret = DllCall("kernel32.dll", "int", "GetSystemPowerStatus", "ptr", DllStructGetPtr($SystemPower))
If @error Then;DllCall Failed
SetError(-2)
$SystemPower = 0
Return $array
EndIf
If Not $ret Then; GetSystemPowerStatus Failed
SetError(-3)
$SystemPower = 0
Return $array
EndIf
; Fill the array
$array = DllStructGetData($SystemPower, 1); AC
$array = DllStructGetData($SystemPower, 2); Battery Charge
$array = DllStructGetData($SystemPower, 3); Battery Charge %
$array = DllStructGetData($SystemPower, 5); Sec Battery Left
; free the struct
$SystemPower = 0
Return $array
EndFunc;==>_BatteryQuery 解决了,谢三恨!!!!!!!!! 怎么解决的啊,发出来让大家都学一下嘛。
页:
[1]