Time zone and cities
Posted: Sat Apr 26, 2014 9:32 pm
I have been experimenting with reading the Windows registry, and quickly put together this short piece which returns the current time zone, as well as the cities mentioned in the Date/Time Control Panel.
Because the key that holds the time zone key name varies between XP and more recent versions of Windows, I start by pulling the Windows version, and change the key name accordingly before reading the register for time zone and cities.
Because the key that holds the time zone key name varies between XP and more recent versions of Windows, I start by pulling the Windows version, and change the key name accordingly before reading the register for time zone and cities.
Code: Select all
on mouseUp
put queryRegistry("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductName") into WVersion
put WVersion into buff
if char 1 to 10 of buff = "Windows XP" then
put "StandardName" into zname
else
put "TimeZoneKeyName" into zname
end if
put queryRegistry("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\TimeZoneInformation\" & zname) into TimeZ
//We look for a key called Display and return the cities
put queryRegistry("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\Romance Standard Time\Display") into cities
answer TimeZ & "/" & cities
end mouseUp