How to set a specific timezone for windows CE By C#

1k views Asked by At

hi everyone i need to make the time zone for my windows CE 6 changed to "(GMT +03:00) Kuwait, Riyadh" and this my code

[DllImport("coredll.dll", CharSet = CharSet.Auto)]

private static extern int GetTimeZoneInformation(out TimeZoneInformation lpTimeZoneInformation);



[DllImport("coredll.dll", CharSet = CharSet.Auto)]

private static extern bool SetTimeZoneInformation(ref TimeZoneInformation lpTimeZoneInformation);



[StructLayout(LayoutKind.Sequential)]

public struct SYSTEMTIME
{

    public int wYear;

    public int wMonth;

    public int wDayOfWeek;

    public int wDay;

    public int wHour;

    public int wMinute;

    public int wSecond;

    public int wMilliseconds;

}



[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]

public struct TimeZoneInformation
{

    public int bias;

    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]

    public string standardName;

    public SYSTEMTIME standardDate;

    public int standardBias;

    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]

    public string daylightName;

    public SYSTEMTIME daylightDate;

    public int daylightBias;

}

how can I use this code to set the time zone for the specific one please any one can help me.

1

There are 1 answers

0
ahmed mohamady On

I found the solution by adding a registry file with this script.

[HKEY_LOCAL_MACHINE\Time Zones]
        "Default"="Arab Standard Time"