private static WindowsTimeZoneCollection LoadTimeZonesFromRegistry() { WindowsTimeZoneCollection tzs = new WindowsTimeZoneCollection(); RegistryKey timeZoneListKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones", false); string[] timeZoneKeyNames = timeZoneListKey.GetSubKeyNames(); foreach (string timeZoneKeyName in timeZoneKeyNames) { RegistryKey timeZoneKey = timeZoneListKey.OpenSubKey(timeZoneKeyName); WindowsTimeZone windowsTimeZone = new WindowsTimeZone( timeZoneKey.GetValue("Display") as string, timeZoneKey.GetValue("Dlt") as string, timeZoneKey.GetValue("Std") as string, (int)timeZoneKey.GetValue("Index"), timeZoneKey.GetValue("TZI") as byte[]); tzs.Add(windowsTimeZone); } tzs.SortByTimeZoneBias(); return(tzs); }
private static WindowsTimeZoneCollection LoadTimeZonesFromRegistry() { WindowsTimeZoneCollection tzs = new WindowsTimeZoneCollection(); RegistryKey timeZoneListKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones", false); string[] timeZoneKeyNames = timeZoneListKey.GetSubKeyNames(); foreach (string timeZoneKeyName in timeZoneKeyNames) { RegistryKey timeZoneKey = timeZoneListKey.OpenSubKey(timeZoneKeyName); WindowsTimeZone windowsTimeZone = new WindowsTimeZone( timeZoneKey.GetValue("Display") as string, timeZoneKey.GetValue("Dlt") as string, timeZoneKey.GetValue("Std") as string, (int)timeZoneKey.GetValue("Index" ), timeZoneKey.GetValue("TZI") as byte[] ); tzs.Add( windowsTimeZone ); } tzs.SortByTimeZoneBias(); return tzs; }