问题描述
- com程序进入线程后抛出异常
-
异常:
test.exe 中的 0x7663c42d 处未处理的异常: Microsoft C++ 异常: 内存位置 0x0470f760 处的 COleException。
线程:
UINT DeviceAnalysis( LPVOID pParam )
{
CMainDialog* threaddlg = (CMainDialog*)pParam;
variant_t vtDeviceId, vtDeviceIds;
threaddlg-> job.GetAllDeviceIds(&vtDeviceIds);
CString str;
for(long index=1; index<=1000 && threaddlg->devanalysisflag; ++index)
{
/*SafeArrayGetElement(vtDeviceIds.parray, &index, &vtDeviceId); /
str.Format(_T("解析了%d"),index);
threaddlg->m_statusbar->SetText(str,0,0);
Sleep(50);
}
if (threaddlg->devanalysisflag == false)
{
}
return 0;
}
异常处:
long GetAllDeviceIds(VARIANT * ids)
{
long result;
static BYTE parms[] = VTS_PVARIANT ;
_*InvokeHelper(0x16, DISPATCH_METHOD, VT_I4, (void*)&result, parms, ids);**
return result;
}
解决方案
解决方案二:
不要在线程中更新界面。http://www.360doc.com/content/12/0227/15/1291795_190019081.shtml
时间: 2024-09-12 21:21:08