Sign in to follow this  
Followers 0
bcording

Determine Laptop

2 posts in this topic

I wrote this function to find out if an XP computer has a battery. Figuring if it has a battery it must be a laptop. I expect someone will clean it up, but here it is in it's raw form.

Func HasBattery()
    Dim $Rootkey = "HKLM\SYSTEM\CurrentControlSet\Enum\ACPI"
    Dim $Key, $SubKey, $i, $i2

    For $i = 1 To 2000
        $Key = RegEnumKey($RootKey, $i)
        If $Key = "" Then ExitLoop
        For $i2 = 1 To 2000
            $SubKey = RegEnumKey($RootKey & "\" & $Key, $i2)
            If $SubKey = "" Then ExitLoop
            $Class = RegRead($RootKey & "\" & $Key & "\" & $SubKey, "Class")
            If $Class = "Battery" Then Return 1
        Next     
    Next
    Return 0
EndFunc

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

@Larry, I have cool idea. How bbout a DllCall to find out about remaining battery power?

EDIT: foo, seems that the battery power api needs a structure to dump info into.

Edited by this-is-me

Who else would I be?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0