Julma Henri (06-07-2013)
Heyy Guys Well here is an easy and fun tut .
So open up vb and make a project
resize however you want and add only 1 label(The label will show us our laptops battery energy.)
So here is the code
Code:Imports System.Runtime.InteropServices Public Class Form1 Dim myManagedPower As New ManagedPower() Sub New() InitializeComponent() Label1.Text = myManagedPower.ToString() End Sub End Class Public Class ManagedPower Declare Auto Function GetSystemPowerStatus Lib "kernel32.dll" _ Alias "GetSystemPowerStatus" (ByRef sps As SystemPowerStatus) As Boolean Public Overrides Function ToString() As String Dim text As String = "" Dim sysPowerStatus As SystemPowerStatus If ManagedPower.GetSystemPowerStatus(sysPowerStatus) Then Dim currentPowerStatus = sysPowerStatus.ACLineStatus text += "Power source: " + sysPowerStatus.ACLineStatus.ToString() + Environment.NewLine text += "Power status: " If sysPowerStatus.BatteryFlag = ManagedPower._BatteryFlag.Unknown Then text += "Unknown" Else Dim fCharging = (ManagedPower._BatteryFlag.Charging = _ (sysPowerStatus.BatteryFlag & ManagedPower._BatteryFlag.Charging)) If fCharging Then Dim currentChargingStatus = ManagedPower._BatteryFlag.Charging End If Dim currentPowerLevel As String If sysPowerStatus.BatteryFlag = 0 Then currentPowerLevel = "Medium " Else currentPowerLevel = sysPowerStatus.BatteryFlag.ToString() End If text += currentPowerLevel If fCharging Then Dim currentChargingStatus = ManagedPower._BatteryFlag.Charging.ToString() text += " (" + ManagedPower._BatteryFlag.Charging.ToString() + ") " End If End If ' Finally print the percentage of the battery life remaining. Dim currentBatteryPercentage = sysPowerStatus.BatteryLifePercent text += Environment.NewLine + "Battery life remaining is " + _ sysPowerStatus.BatteryLifePercent.ToString() + "%" End If Return text End Function <StructLayout(LayoutKind.Sequential)> _ Public Structure SystemPowerStatus Public ACLineStatus As _ACLineStatus Public BatteryFlag As _BatteryFlag Public BatteryLifePercent As Byte Public Reserved1 As Byte Public BatteryLifeTime As System.UInt32 Public BatteryFullLifeTime As System.UInt32 End Structure Public Enum _ACLineStatus As Byte Battery = 0 AC = 1 Unknown = 255 End Enum <Flags()> _ Public Enum _BatteryFlag As Byte High = 1 Low = 2 Critical = 4 Charging = 8 NoSystemBattery = 128 Unknown = 255 End Enum End Class
Julma Henri (06-07-2013)
It's copied from online sources:
*links*
Last edited by Jorndel; 06-12-2013 at 02:05 PM.
- Gone; this is another shit forum with children as administrators. Not worth contributing to.
Weather it was copied or not, at least he's trying to make this section active.
guys, so what if he wanted yall to know this code? who cares. what if i went to google and couldnt find it? well it would be here at MPGH waiting for me.
This is copy pasted code from online, which makes me sad. You should at least make the code more efficient, the efficiency of the code is poor.
Her picture where ?
I want to see Screenshot