Jump to content
Sign in to follow this  

Determine Laptop

Recommended Posts


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
    Return 0

Share this post

Link to post
Share on other sites

@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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.