Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Func _GetNetConnection()
- Local $aReturn = DllCall('connect.dll', 'long', 'IsInternetConnected')
- If @error Then
- Return SetError(1, 0, False)
- EndIf
- Return $aReturn[0] = 0
- EndFunc ;==>_IsInternetConnected
- Func _Battery_StartUp()
- Local $o_WMIService = ObjGet("winmgmts:\\localhost\root\CIMV2")
- Return $o_WMIService.ExecQuery("SELECT * FROM Win32_Battery", "WQL", 48)
- EndFunc
- Func _Battery_IsCharging()
- Local $o_item, $_state = Default, $o_object = _Battery_StartUp()
- If IsObj($o_object) Then
- For $o_item in $o_object
- $_state = $o_item.BatteryStatus
- next
- If $_state < 0 Or $_state > 7 Then
- Return SetError(-2)
- Else
- If $_state = 2 Then
- Return True
- Else
- Return False
- EndIf
- EndIf
- Else
- Return SetError(-1)
- EndIf
- EndFunc
- Func _Battery_GetCharge()
- Local $o_item, $o_object = _Battery_StartUp()
- If IsObj($o_object) Then
- For $o_item in $o_object
- Return $o_item.EstimatedChargeRemaining
- Next
- Else
- Return SetError(-1)
- EndIf
- EndFunc
- Func _Battery_GetVoltage()
- Local $o_item, $o_object = _Battery_StartUp()
- If IsObj($o_object) Then
- For $o_item in $o_object
- Return ($o_item.DesignVoltage/1000)
- Next
- Else
- Return SetError(-1)
- EndIf
- EndFunc
- Func GetCPUUsage()
- Local $wbemFlags = 0x10 + 0x20
- Local $objWMIService = ObjGet("winmgmts:\\" & @ComputerName & "\root\CIMV2")
- Local $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", $wbemFlags)
- Local $c = 0
- Local $sMsg = ""
- For $objItem In $colItems
- $sMsg &= "cpu%" & $objItem.LoadPercentage
- Next
- $CpuAuslastung = StringSplit($sMsg, "cpu%", 1)
- For $n = "0" To $CpuAuslastung[0]
- $c += $CpuAuslastung[$n]
- Next
- Return (Round($c / $CpuAuslastung[0], 0))
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement