一次内存冲突问题
time = CTime::GetCurrentTime(); strTime = time.Format("%Y年%m月%d日%A,%H:%M:%S"); StrTimeN = time.Format("%Y年%m月%d日%a,%H:%M:%S"); //::SetDlgItemText(AfxGetMainWnd()->m_hWnd, IDC_TIME, strTime); //在vc6.0以后的版本中不支持AfxGetMainWnd()->m_hWnd来获取HWND //改为SetDlgItemText(AfxGetApp()->m_pMainWnd->m_hWnd,IDC_TIME, strTime); SetDlgItemText(AfxGetApp()->m_pMainWnd->m_hWnd, IDC_TIME, strTime); SetDlgItemText(AfxGetApp()->m_pMainWnd->m_hWnd, IDC_STATIC, StrTimeN); Sleep(1000);
在VC6.0以上版本使用::SetDlgItemText(AfxGetMainWnd()->m_hWnd, IDC_TIME, strTime);
会有未经处理的异常: 0xC0000005: 读取位置 0x00000020 时发生访问冲突。