K
Ken Varn
I have a managed C++ method that I call from ASP.NET to set the time zone on
the local box. I call SetTimeZoneInformation, which does not return an
error, but the time zone remains unchanged. I have checked the web for any
information on this, but have not found any articles that relate to this
specific problem. Can anyone tell me what is wrong here?
Here is a sample snippet of the method:
Note that TimeZoneInfo is my own managed version of the native
TIME_ZONE_INFORMATION structure.
void SystemDateTime::SetTimeZoneInfo(TimeZoneInfo ZoneInfo)
{
TIME_ZONE_INFORMATION TZInfo = {0};
DWORD Result;
const wchar_t __pin *Name;
TZInfo.Bias = ZoneInfo.Bias;
TZInfo.StandardDate = DateTimeToSysTime(ZoneInfo.StandardDate);
Name = PtrToStringChars(ZoneInfo.StandardName);
wcscpy(TZInfo.StandardName,Name);
TZInfo.StandardBias = ZoneInfo.StandardBias;
Name = PtrToStringChars(ZoneInfo.DaylightName);
wcscpy(TZInfo.DaylightName,Name);
TZInfo.DaylightDate = DateTimeToSysTime(ZoneInfo.DaylightDate);
TZInfo.DaylightBias = ZoneInfo.DaylightBias;
if (!::SetTimeZoneInformation(&TZInfo))
{
int ErrorCode = GetLastError();
throw __gc new Win32Exception(ErrorCode,GetErrorMsg(ErrorCode));
}
SendMessageTimeout(HWND_BROADCAST,WM_SETTINGCHANGE,0,(LPARAM)
"intl",SMTO_BLOCK,15000,&Result);
}
SYSTEMTIME SystemDateTime:ateTimeToSysTime(DateTime DT)
{
SYSTEMTIME Ret = {0};
COleDateTime OleDT;
OleDT = DT.ToOADate();
OleDT.GetAsSystemTime(Ret);
return Ret;
}
--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.
EmailID = varnk
Domain = Diebold.com
-----------------------------------
the local box. I call SetTimeZoneInformation, which does not return an
error, but the time zone remains unchanged. I have checked the web for any
information on this, but have not found any articles that relate to this
specific problem. Can anyone tell me what is wrong here?
Here is a sample snippet of the method:
Note that TimeZoneInfo is my own managed version of the native
TIME_ZONE_INFORMATION structure.
void SystemDateTime::SetTimeZoneInfo(TimeZoneInfo ZoneInfo)
{
TIME_ZONE_INFORMATION TZInfo = {0};
DWORD Result;
const wchar_t __pin *Name;
TZInfo.Bias = ZoneInfo.Bias;
TZInfo.StandardDate = DateTimeToSysTime(ZoneInfo.StandardDate);
Name = PtrToStringChars(ZoneInfo.StandardName);
wcscpy(TZInfo.StandardName,Name);
TZInfo.StandardBias = ZoneInfo.StandardBias;
Name = PtrToStringChars(ZoneInfo.DaylightName);
wcscpy(TZInfo.DaylightName,Name);
TZInfo.DaylightDate = DateTimeToSysTime(ZoneInfo.DaylightDate);
TZInfo.DaylightBias = ZoneInfo.DaylightBias;
if (!::SetTimeZoneInformation(&TZInfo))
{
int ErrorCode = GetLastError();
throw __gc new Win32Exception(ErrorCode,GetErrorMsg(ErrorCode));
}
SendMessageTimeout(HWND_BROADCAST,WM_SETTINGCHANGE,0,(LPARAM)
"intl",SMTO_BLOCK,15000,&Result);
}
SYSTEMTIME SystemDateTime:ateTimeToSysTime(DateTime DT)
{
SYSTEMTIME Ret = {0};
COleDateTime OleDT;
OleDT = DT.ToOADate();
OleDT.GetAsSystemTime(Ret);
return Ret;
}
--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.
EmailID = varnk
Domain = Diebold.com
-----------------------------------