public
static
TimeZoneInformation[] EnumZones()
{
if ( s_zones == null )
{
lock( s_lockZones )
{
if ( s_zones == null )
{
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 )
tzi.m_index = (int)( subKey.GetValue( "Index" ) );
tzi.InitTzi( (byte[]) subKey.GetValue( "Tzi" ) );
zones.Add( tzi );
}
}
}
s_zones = new TimeZoneInformation[ zones.Count ];
zones.CopyTo( s_zones );
}
}
}
return s_zones;
}
{
if ( s_zones == null )
{
lock( s_lockZones )
{
if ( s_zones == null )
{
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.m_displayName = (string) subKey.GetValue( "Display" );
tzi.m_standardName = (string) subKey.GetValue( "Std" );
tzi.m_index = (int)( subKey.GetValue( "Index" ) );
tzi.InitTzi( (byte[]) subKey.GetValue( "Tzi" ) );
zones.Add( tzi );
}
}
}
s_zones = new TimeZoneInformation[ zones.Count ];
zones.CopyTo( s_zones );
}
}
}
return s_zones;
}