在执行以下代码时,我遇到了一些内存访问冲突:
UINT cDims = 1;
SAFEARRAYBOUND rgsabound[1];
long lLbound = 0;
long lUbound = 0;
rgsabound[0].lLbound = 0;
rgsabound[0].cElements = pList1->rgsabound[0].cElements + pList2->rgsabound[0].cElements;
SAFEARRAY* mergeResult = SafeArrayCreate(VT_DISPATCH, cDims, reinterpret_cast<SAFEARRAYBOUND*>(rgsabound));
// Obtain bounds information of the SAFEARRAY.
SafeArrayGetLBound(pList2, 1, &lLbound);
SafeArrayGetUBound(pList2, 1, &lUbound);
long lDimSize = lUbound - lLbound + 1;
GoldMineConstantContactCOM::IBounceActivityPtr ptrActivity;
SafeArrayCopy(pList1, &mergeResult);
rgsabound[0].lLbound = 0;
rgsabound[0].cElements = pList1->rgsabound[0].cElements + pList2->rgsabound[0].cElements;
SafeArrayRedim(mergeResult, rgsabound);
for (int i = 0; i < lDimSize; i++)
{
long rgIndices[1];
rgIndices[0] = i;
HRESULT hRes2 = SafeArrayGetElement(pList2, rgIndices, &ptrActivity);
rgIndices[0] = rgIndices[0] + pList1->rgsabound[0].cElements;
HRESULT hRes = SafeArrayPutElement(mergeResult, rgIndices, (void*)&ptrActivity);
}
return mergeResult;
我收到的消息是:0x774115de 处的未处理异常:0xC0000005:访问冲突读取位置 0x00000004。
任何帮助都会非常有帮助!
提前致谢
问候, 法比安