我收到 E_INVALIDARG 错误
STDMETHODIMP CDocumentController::HasPrivEventCode(double dUserId,double dPosCd,double dPPRCd,SAFEARRAY** pEventCode)
{
// TODO: Add your implementation code here
long lElements; // number of elements in the array
long lCount;
HRESULT lResult; // return code for OLE functions
double *pArrayElements; // pointer to the elements of the array
// checking if it is a one-dimensional array
if ( (*pEventCode)->cDims != 1 ) return(E_FAIL);
// checking if it is an array of double
if ( (*pEventCode)->cbElements != 8 ) return(E_FAIL);
// how many elements are there in the array
lElements=(*pEventCode)->rgsabound[0].cElements;
// locking the array before using its elements
lResult=SafeArrayLock(*pEventCode);
if (lResult != S_OK) return(E_FAIL);
// using the array
pArrayElements=(double*) (*pEventCode)->pvData;
CMap<double,double,bool,bool> mapEventCds;
for (lCount=0; lCount<lElements; lCount++)
{
double lVal = pArrayElements[lCount];
mapEventCds.SetAt(lVal, false);
}
CheckPrivViewResultEventCds(dUserId, dPosCd, dPPRCd, mapEventCds);
long iEventCdIdx(0);
double dEventCd(0.0);
bool bPriv(false);
POSITION pos(mapEventCds.GetStartPosition());
INT_PTR nEventCnt(mapEventCds.GetCount());
double* arrEventCdsWithPriv = new double[nEventCnt];
VARIANT vt;
//(*pEventCode)->pvData = NULL;
lResult=SafeArrayUnlock(*pEventCode);
HRESULT hr = SafeArrayDestroyData(*pEventCode);
for(INT_PTR count(0); count < nEventCnt; ++count)
{
mapEventCds.GetNextAssoc(pos, dEventCd, bPriv);
if (bPriv)
{
vt.vt = VT_R8;
vt.dblVal = dEventCd;
hr = SafeArrayPutElement(*pEventCode, &iEventCdIdx, &dEventCd);
iEventCdIdx++;
}
}
// Empty the CMap
mapEventCds.RemoveAll();
// releasing the array
lResult=SafeArrayUnlock(*pEventCode);
return S_OK;
}
*pEventCode
是我的安全数组...是“双”值...当( )为真时dEventCd
,我想将dEventCd
值*pEventCode
一一插入到我的安全数组中...请帮助bPriv