Time zone and cities

Deploying to Windows? Utilizing VB Script execution? This is the place to ask Windows-specific questions.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
michel_bujardet
Posts: 45
Joined: Mon Apr 21, 2014 10:41 am
Contact:

Time zone and cities

Post by michel_bujardet » 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.

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

Mitch
http://FontMenu.com

Post Reply