It is relatively new to the C ++ world. I want to access data from multidimensional SAFEARRAY. However, when I try to get the value, I get the error 0xC0000005: Location of access violation detection 0x40e3e300. The code below is mine, and the marked line is an error. Hope someone can shed some light on how to solve it.
SAFEARRAY *ArrayCrosstabInfo = GetMainFrame().m_epsComHelper->GetCrosstab(m_arrayFieldnames,start,end);
COleSafeArray ArrayCrosstab(*ArrayCrosstabInfo,VT_SAFEARRAY);
BSTR *DataValue;
ArrayCrosstab.AccessData((void**) &DataValue);
long lUBoundX;
long lUBoundY;
ArrayCrosstab.GetUBound(1,&lUBoundX);
ArrayCrosstab.GetUBound(2,&lUBoundY);
long lOffset = 2;
int nFieldIndex = 0;
if (lUBoundX > 0 && lUBoundY > 0)
{
for (long i = lOffset; i<=lUBoundY; i++)
{
_bstr_t theData((BSTR)DataValue[0,i],FALSE); <==ERRORS HERE
}
}
source
share