Are there any way to enable and disable DST (Daylight Saving Time) on Windows OS by code?
I have been following the steps mentioned on the next link, but without success...
Also I have been trying changing "Bias" property of DYNAMIC_TIME_ZONE_INFORMATION
struct, it allows me to change date time, but not to enable or disable DST...
Are there any way to solve this problem?
The next source code only disables DST, nevertheless I need to enable again...
OpenProcessToken(::GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken);
TOKEN_PRIVILEGES tp;
LookupPrivilegeValue(NULL, SE_TIME_ZONE_NAME, &tp.Privileges[0].Luid);
tp.PrivilegeCount = 1;
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hToken, FALSE, &tp, 0, (PTOKEN_PRIVILEGES)NULL, 0);
DYNAMIC_TIME_ZONE_INFORMATION dyTimeZoneInfo;
ZeroMemory(&dyTimeZoneInfo, sizeof(dyTimeZoneInfo));
DWORD tzId = GetDynamicTimeZoneInformation(&dyTimeZoneInfo);
dyTimeZoneInfo.DynamicDaylightTimeDisabled = !dyTimeZoneInfo.DynamicDaylightTimeDisabled;
dyTimeZoneInfo.DaylightBias = 0;
dyTimeZoneInfo.StandardDate.wDay = 0;
dyTimeZoneInfo.StandardDate.wDayOfWeek = 0;
dyTimeZoneInfo.StandardDate.wHour = 0;
dyTimeZoneInfo.StandardDate.wMilliseconds = 0;
dyTimeZoneInfo.StandardDate.wMinute = 0;
dyTimeZoneInfo.StandardDate.wMonth = 0;
dyTimeZoneInfo.StandardDate.wSecond = 0;
dyTimeZoneInfo.StandardDate.wYear = 0;
dyTimeZoneInfo.DaylightDate.wDay = 0;
dyTimeZoneInfo.DaylightDate.wDayOfWeek = 0;
dyTimeZoneInfo.DaylightDate.wHour = 0;
dyTimeZoneInfo.DaylightDate.wMilliseconds = 0;
dyTimeZoneInfo.DaylightDate.wMinute = 0;
dyTimeZoneInfo.DaylightDate.wMonth = 0;
dyTimeZoneInfo.DaylightDate.wSecond = 0;
dyTimeZoneInfo.DaylightDate.wYear = 0;
SetDynamicTimeZoneInformation(&dyTimeZoneInfo);
tp.Privileges[0].Attributes = NULL;
AdjustTokenPrivileges(hToken, FALSE, &tp, 0, (PTOKEN_PRIVILEGES)NULL, 0);
CloseHandle(hToken);
I will appreciate any kind of help.