Hello,
In fact, my collegue made a configuration application (for windows ce 4.2)
which configured all parameters
of system as the time zone when we installed a another program.
I need to synchronise datas with a server and I am in France, therefore I
want to change the default parameter.
The server sends the date and hour for the device.
I tried this code under windows ce 5.0, but the
RechercheFuseauHoraire("timezone")function returned always false.
the code :
---------------------------------------------------------------------------------------
public static bool RechercheFuseauHoraire(string pFuseauRech)
{
TimeZoneInformation tzi = null;
try
{
if (DateTimeEx.GetTimeZoneInformation(ref tzi) !=
TimeZoneState.Unknown)
{
if (EnleveCaracNull(tzi.StandardName) ==
pFuseauRech.Trim())
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
catch
{
return false;
}
}
/// <summary>
/// Modifie le fuseau horaire utilisé par Windows
/// </summary>
/// <param name="pFuseau">Nom standard du fuseau horaire à
utiliser</param>
/// <returns>True si OK, False sinon</returns>
public static bool DefinitFuseauHoraire(string pFuseau)
{
TimeZoneCollection lstTimeZone;
try
{
lstTimeZone = new TimeZoneCollection();
lstTimeZone.Initialize(1);
// On parcourt la liste des fuseaux possibles
foreach (TimeZoneInformation objTimezone in lstTimeZone)
{
// Une fois qu'on a trouvé le fuseau à appliquer...
if (EnleveCaracNull(objTimezone.StandardName.Trim()) ==
pFuseau.Trim())
{
//... on le définit comme fuseau utilisé par
Windows...
OpenNETCF.Win32.TimeZoneInformation tzi = new TimeZoneInformation();
DateTimeEx.SetTimeZoneInformation(objTimezone);
//... et on force le système à rafraîchir la variable d'environnement
qui définit
// le nom du fuseau utilisé
FieldInfo fi =
typeof(TimeZone).GetField("currentTimeZone",
BindingFlags.NonPublic|BindingFlags.Static|BindingFlags.Instance);
fi.SetValue(null, null);
return true;
}
}
return false;
}
catch
{
return false;
}
}
---------------------------------------------------------------------------------------
Best regards.
"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> a écrit dans le message de (e-mail address removed)...
"Works" and "doesn't work" is pretty useless information. What actually
happens?
The same call would be used in CE5 as in CE4.x to change the time zone
characteristics, SetTimeZoneInformation(). The parameters to the call
have not changed. You must be doing something wrong, but with the little
information you've given, I can't imagine what it is.
Also, what exactly are you trying to accomplish? I think that every time
zone in the world is already in the registry in CE5. Why would you need
to 'change' it?
Paul T.