Jump to content

Determine Laptop


bcording
 Share

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
        Next     
    Next
    Return 0
EndFunc
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...