Daylight Saving Time Registry Settings (Windows Embedded CE 6.0)
1/6/2010
The following registry key example shows how to set the operating system to daylight saving time during cold or warm boot.
[HKEY_LOCAL_MACHINE\Software\Microsoft\Clock]
"HomeDST": REG_DWORD
If you set this registry value to 1, daylight saving time is enabled for the current time zone when the OS boots. The OS reads the current time zone when the OS boots. If you set this registry value to 0, daylight saving time is disabled the next time the OS boots. The OS reads this registry value only when the OS boots. If the OS cannot find this registry value, the OS uses the default value of 0.
For Windows Embedded CE, the registry key for daylight saving time is not present by default. There is no auto-adjust for daylight saving time. The registry key is created on demand, for example, when the clock application is activated. If the key is present, the value of the registry key should be used as is, for the .NET Compact Framework logic to work, that is, for DateTime.Now to return a coherent value.
Note
You can use the SetDaylightTime function to enable or disable daylight saving time in code.
Ramifications of the Energy Policy Act
On August 8, 2005, the Energy Policy Act was signed into law to extend daylight saving time by approximately four weeks. Starting in the spring of 2007, the start date is three weeks earlier (2:00 A.M. on the second Sunday in March), and the end date is one week later (2:00 A.M. on the first Sunday in November).
The following time zones are affected:
- (GMT-03:30) Newfoundland
- (GMT-04:00) Atlantic Time (Canada)
- (GMT-05:00) Eastern Time (US & Canada)
- (GMT-06:00) Central Time (US & Canada)
- (GMT-07:00) Mountain Time (US & Canada)
- (GMT-08:00) Pacific Time (US & Canada)
- (GMT-09:00) Alaska
Microsoft updated the daylight savings time data to reflect the new start and end dates and times.
Pre-Energy Policy Act Registry Settings
The standard time zone name corresponds to the StandardName member of the TIME_ZONE_INFORMATION structure, so the same rules and conditions that apply to the structure apply to this registry key.
The time zone data can be found in the following file: %_WINCEROOT%\Public\Common\OAK\Files\common.reg
Note
Only the line of data that begin with "TZI"= needs to be modified. Do not modify the lines beginning with "Display"=, "Dlt"=, and "Std"= because they must match the resource file.
[HKEY_LOCAL_MACHINE\Time Zones\Newfoundland Standard Time]
"Display"=mui_sz:"coredll.dll,#32788"
"Dlt"=mui_sz:"coredll.dll,#33044"
"Std"=mui_sz:"coredll.dll,#33300"
"TZI"=hex:d2,00,00,00,00,00,00,00,c4,ff,ff,ff,\
00,00,0a,00,00,00,05,00,02,00,00,00,00,00,00,00,\
00,00,04,00,00,00,01,00,02,00,00,00,00,00,00,00
[HKEY_LOCAL_MACHINE\Time Zones\Atlantic Standard Time]
"Display"=mui_sz:"coredll.dll,#32783"
"Dlt"=mui_sz:"coredll.dll,#33039"
"Std"=mui_sz:"coredll.dll,#33295"
"TZI"=hex:f0,00,00,00,00,00,00,00,c4,ff,ff,ff,\
00,00,0a,00,00,00,05,00,02,00,00,00,00,00,00,00,\
00,00,04,00,00,00,01,00,02,00,00,00,00,00,00,00
[HKEY_LOCAL_MACHINE\Time Zones\Eastern Standard Time]
"Display"=mui_sz:"coredll.dll,#32780"
"Dlt"=mui_sz:"coredll.dll,#33036"
"Std"=mui_sz:"coredll.dll,#33292"
"TZI"=hex:2c,01,00,00,00,00,00,00,c4,ff,ff,ff,\
00,00,0a,00,00,00,05,00,02,00,00,00,00,00,00,00,\
00,00,04,00,00,00,01,00,02,00,00,00,00,00,00,00
[HKEY_LOCAL_MACHINE\Time Zones\Central Standard Time]
"Display"=mui_sz:"coredll.dll,#32776"
"Dlt"=mui_sz:"coredll.dll,#33032"
"Std"=mui_sz:"coredll.dll,#33288"
"TZI"=hex:68,01,00,00,00,00,00,00,c4,ff,ff,ff,\
00,00,0a,00,00,00,05,00,02,00,00,00,00,00,00,00,\
00,00,04,00,00,00,01,00,02,00,00,00,00,00,00,00
[HKEY_LOCAL_MACHINE\Time Zones\Mountain Standard Time]
"Display"=mui_sz:"coredll.dll,#32773"
"Dlt"=mui_sz:"coredll.dll,#33029"
"Std"=mui_sz:"coredll.dll,#33285"
"TZI"=hex:a4,01,00,00,00,00,00,00,c4,ff,ff,ff,\
00,00,0a,00,00,00,05,00,02,00,00,00,00,00,00,00,\
00,00,04,00,00,00,01,00,02,00,00,00,00,00,00,00
[HKEY_LOCAL_MACHINE\Time Zones\Pacific Standard Time]
"Display"=mui_sz:"coredll.dll,#32772"
"Dlt"=mui_sz:"coredll.dll,#33028"
"Std"=mui_sz:"coredll.dll,#33284"
"TZI"=hex:e0,01,00,00,00,00,00,00,c4,ff,ff,ff,\
00,00,0a,00,00,00,05,00,02,00,00,00,00,00,00,00,\
00,00,04,00,00,00,01,00,02,00,00,00,00,00,00,00
[HKEY_LOCAL_MACHINE\Time Zones\Alaskan Standard Time]
"Display"=mui_sz:"coredll.dll,#32771"
"Dlt"=mui_sz:"coredll.dll,#33027"
"Std"=mui_sz:"coredll.dll,#33283"
"TZI"=hex:1c,02,00,00,00,00,00,00,c4,ff,ff,ff,\
00,00,0a,00,00,00,05,00,02,00,00,00,00,00,00,00,\
00,00,04,00,00,00,01,00,02,00,00,00,00,00,00,00
Post-Energy Policy Act Registry Settings
The following registry settings are default for CE 6.0.
Note
Only the line of data that begin with "TZI"= needs to be modified. Do not modify the lines beginning with "Display"=, "Dlt"=, and "Std"= because they must match the resource file.
[HKEY_LOCAL_MACHINE\Time Zones\Newfoundland Standard Time]
"Display"=mui_sz:"coredll.dll,#32788"
"Dlt"=mui_sz:"coredll.dll,#33044"
"Std"=mui_sz:"coredll.dll,#33300"
"TZI"=hex:d2,00,00,00,00,00,00,00,c4,ff,ff,ff,\
00,00,0b,00,00,00,01,00,02,00,00,00,00,00,00,00,\
00,00,03,00,00,00,02,00,02,00,00,00,00,00,00,00
[HKEY_LOCAL_MACHINE\Time Zones\Atlantic Standard Time]
"Display"=mui_sz:"coredll.dll,#32783"
"Dlt"=mui_sz:"coredll.dll,#33039"
"Std"=mui_sz:"coredll.dll,#33295"
"TZI"=hex:f0,00,00,00,00,00,00,00,c4,ff,ff,ff,\
00,00,0b,00,00,00,01,00,02,00,00,00,00,00,00,00,\
00,00,03,00,00,00,02,00,02,00,00,00,00,00,00,00
[HKEY_LOCAL_MACHINE\Time Zones\Eastern Standard Time]
"Display"=mui_sz:"coredll.dll,#32780"
"Dlt"=mui_sz:"coredll.dll,#33036"
"Std"=mui_sz:"coredll.dll,#33292"
"TZI"=hex:2c,01,00,00,00,00,00,00,c4,ff,ff,ff,\
00,00,0b,00,00,00,01,00,02,00,00,00,00,00,00,00,\
00,00,03,00,00,00,02,00,02,00,00,00,00,00,00,00
[HKEY_LOCAL_MACHINE\Time Zones\Central Standard Time]
"Display"=mui_sz:"coredll.dll,#32776"
"Dlt"=mui_sz:"coredll.dll,#33032"
"Std"=mui_sz:"coredll.dll,#33288"
"TZI"=hex:68,01,00,00,00,00,00,00,c4,ff,ff,ff,\
00,00,0b,00,00,00,01,00,02,00,00,00,00,00,00,00,\
00,00,03,00,00,00,02,00,02,00,00,00,00,00,00,00
[HKEY_LOCAL_MACHINE\Time Zones\Mountain Standard Time]
"Display"=mui_sz:"coredll.dll,#32773"
"Dlt"=mui_sz:"coredll.dll,#33029"
"Std"=mui_sz:"coredll.dll,#33285"
"TZI"=hex:a4,01,00,00,00,00,00,00,c4,ff,ff,ff,\
00,00,0b,00,00,00,01,00,02,00,00,00,00,00,00,00,\
00,00,03,00,00,00,02,00,02,00,00,00,00,00,00,00
[HKEY_LOCAL_MACHINE\Time Zones\Pacific Standard Time]
"Display"=mui_sz:"coredll.dll,#32772"
"Dlt"=mui_sz:"coredll.dll,#33028"
"Std"=mui_sz:"coredll.dll,#33284"
"TZI"=hex:e0,01,00,00,00,00,00,00,c4,ff,ff,ff,\
00,00,0b,00,00,00,01,00,02,00,00,00,00,00,00,00,\
00,00,03,00,00,00,02,00,02,00,00,00,00,00,00,00
[HKEY_LOCAL_MACHINE\Time Zones\Alaskan Standard Time]
"Display"=mui_sz:"coredll.dll,#32771"
"Dlt"=mui_sz:"coredll.dll,#33027"
"Std"=mui_sz:"coredll.dll,#33283"
"TZI"=hex:1c,02,00,00,00,00,00,00,c4,ff,ff,ff,\
00,00,0b,00,00,00,01,00,02,00,00,00,00,00,00,00,\
00,00,03,00,00,00,02,00,02,00,00,00,00,00,00,00
Sample Code to Update the Registry
The following sample code checks the current date and when it is January 1, 2007, runs the registry modification to the new setting. Atlantic Standard Time is used as an example.
#include <windows.h>
// New value for Atlantic Standard Time
BYTE bNewVal[44] = {0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc4,0xff,0xff,0xff,0x00,0x00,0x0b,0x00,0x00,0x00,0x01,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x02,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00
} ;
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nShowCmd )
{
HKEY hKey;
LONG retCode;
BYTE bVal[44];
DWORD dwType = REG_BINARY;
DWORD dwSize = sizeof(bVal);
SYSTEMTIME st;
GetSystemTime(&st);
// This check updates the registry whenever this code runs starting January 1, 2007.
if(st.wYear > 2006){
if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Time Zones\\Atlantic Standard Time", 0, 0, &hKey)){
if ((ERROR_SUCCESS == RegQueryValueEx(hKey, L"TZI", NULL, &dwType, (BYTE*) &bVal, &dwSize)) && (dwType == REG_BINARY))
{
// Check registry value to see if old value.
// This check needs to be changed depending on time zone being updated.
if(bVal[30] == 0x04)
{
retCode = RegSetValueEx(hKey, L"TZI", 0, REG_BINARY, (BYTE*) &bNewVal, sizeof(bNewVal));
if(ERROR_SUCCESS != retCode)
NKDbgPrintfW (_T("Failed to write to registry...\r\n"));
}
}
}
}
if(hKey){
RegFlushKey(hKey);
RegCloseKey(hKey);
}
return 0;
}
// If you have the automatic DST service (timesvc.dll) included in your image, you must update it after changing the timezone information in the regsitry. The following source code will perform this:
extern "C" void RefreshTimeSvc()
{
HANDLE hFile;
hFile = CreateFile(L"NTP0:",GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,0,NULL);
if (INVALID_HANDLE_VALUE == hFile)
return;
DeviceIoControl(hFile,IOCTL_SERVICE_REFRESH,0,0,0,0,NULL,0);
CloseHandle(hFile);
}