Skip to content

Instantly share code, notes, and snippets.

@hoppfrosch
Created September 18, 2012 09:33
Show Gist options
  • Save hoppfrosch/3742243 to your computer and use it in GitHub Desktop.
Save hoppfrosch/3742243 to your computer and use it in GitHub Desktop.
PROBLEM: Determine number of Array elements [#ahk #problem
test := GetTimeZones()
ExitApp
GetTimeZones() {
; Taken from: http://www.autohotkey.com/community/viewtopic.php?t=73951
OutputDebug % "**** GetTimeZones START ****"
; Get the "Time Zones" entries from registry
RegRoot := "HKEY_LOCAL_MACHINE"
RegKey := "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones"
RegTimeZones := {}
if (!RegTimeZones)
OutputDebug % "!RegTimeZones"
Loop, %RegRoot%, %RegKey%, 2
{
RegRead, DSP, %RegRoot%, %RegKey%\%A_LoopRegName%, Display
RegRead, TZI, %RegRoot%, %RegKey%\%A_LoopRegName%, TZI
RegTimeZones[A_LoopRegName] := [DSP, TZI]
OutputDebug % A_Index " - Display,:" RegTimeZones[A_LoopRegName][1] ", TimeZoneInformation" RegTimeZones[A_LoopRegName][2]
}
i := RegTimeZones.MaxIndex()
; Why is i not equal the number of elements within RegTimeZones?
OutputDebug % "GetTimeZones found " RegTimeZones.MaxIndex() "(" i ") Timezones"
OutputDebug % "**** GetTimeZones END ****"
Return RegTimeZones
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment