2009-03-05 80 views
4

有谁知道Windows中的时区名称翻译的编译列表?我需要德语,法语和西班牙语全部75个左右。或者,我将如何使用.Net来编译这样的列表?任何人都知道翻译时区描述的来源?

实施例的格式:(GMT + 01:00)贝尔格莱德,布拉迪斯拉发,布达佩斯,卢布尔雅那,布拉格

回答

1

没有在注册表中的所有时区的列表:

HKEY_LOCAL_MACHINE \ SOFTWARE \微软\的Windows NT \ CURRENTVERSION \时区

可以使用哪种方式加载:

ArrayList zones = new ArrayList(); 

using(RegistryKey key = Registry.LocalMachine.OpenSubKey(
    @"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones")) 
{ 
    string[] zoneNames = key.GetSubKeyNames(); 

    foreach(string zoneName in zoneNames) 
    { 
     using(RegistryKey subKey = key.OpenSubKey(zoneName)) 
     { 
      TimeZoneInformation tzi = new TimeZoneInformation(); 
      tzi.Name = zoneName; 
      tzi.DisplayName = (string)subKey.GetValue("Display"); 
      tzi.StandardName = (string)subKey.GetValue("Std"); 
      tzi.DaylightName = (string)subKey.GetValue("Dlt"); 
      object value = subKey.GetValue("Index"); 
      if(value != null) 
      { 
       tzi.Index = (int)value; 
      } 

      tzi.InitTzi((byte[])subKey.GetValue("Tzi")); 

      zones.Add(tzi); 
     } 
    } 
} 

其中TimeZoneInformation只是一个存储信息以方便访问的类。

您正在查找的说明位于“显示”值中。

+0

这个答案在几个方面似乎是错误的。首先,OP要求翻译的名字。其次,您可以简单地使用TimeZoneInfo.GetSystemTimeZones()而不是显示的代码。 – 2016-03-30 19:32:54

相关问题