Hi all,
I am using Visual Studio 2008 on Windows CE. I am getting a weird stack overflow after calling the MFC function SetLocalTime. There is no code to step into and no call stack.
Here is my code:
void OnBnClickedButtonSet()
{
SYSTEMTIME time, new_time;
GetLocalTime(&time);
time.wYear = static_cast<WORD>(i_year);
time.wMonth = static_cast<WORD>(i_month);
time.wDay = static_cast<WORD>(i_day);
DWORD ret = m_Time.GetTime(&new_time);
if (ret == GDT_VALID)
{
time.wHour = new_time.wHour;
time.wMinute = new_time.wMinute;
time.wSecond = new_time.wSecond;
time.wMilliseconds = 0;
}
else
{
TRACE(_T("not a time format\n"));
return;
}
CString str(_T(""));
if (!SetLocalTime(&time))
{
str.Format(_T("system time error = %d. \n"), GetLastError());
TRACE(str);
return;
}}
SetLocalTime doesn't return an error and sets the chosen values for date/time, even if WindowsCE crashes and it needs restarting. After restarting, the date and time can be set again without any problems...
The Disassembly Window points here: "40060198 stmdb sp!, {r0, r4, r5, lr}". I don't know if this is helpful or not...
i_year, i_month and i_day are variables as int values for 3 edit controls where the user inputs the day, month and year.
Thanks in advance for your help.
CB
N.B. I tried SecureZeroMemory(&time, sizeof(time)) before GetLocalTime(&time) but no change.