Look in MSDN:
SafeArrayGetUBound, SafeArrayGetElement, SafeArrayPutElement and other.
Small functions for manipulate safearray vectors:
void OLECreateVector(long iLen, _variant_t* pvarArr)
{
SAFEARRAYBOUND rgsabound[1];
rgsabound[0].cElements = iLen;
rgsabound[0].lLbound = 0;
SAFEARRAY * psa = SafeArrayCreate(VT_VARIANT, 1, rgsabound);
if(psa == NULL) _com_issue_error(E_OUTOFMEMORY);
pvarArr->vt = VT_ARRAY | VT_VARIANT;
pvarArr->parray = psa;
}
long OLEVectorGetUBound(_variant_t* pvarArr)
{
long lUBound;
HRESULT hRes = SafeArrayGetUBound(pvarArr->parray, 1, &lUBound);
if(hRes != S_OK) _com_issue_error(hRes);
return lUBound;
}
void OLEVectorPutElement(_variant_t* pvarArr, long iX, _variant_t* pvarVal)
{
long Indices[1];
Indices[0] = iX;
HRESULT hRes = SafeArrayPutElement(pvarArr->parray, Indices, pvarVal);
if(hRes != S_OK) _com_issue_error(hRes);
}
void OLEVectorGetElement(_variant_t* pvarArr, long iX, _variant_t* pvarVal)
{
long Indices[1];
Indices[0] = iX;
HRESULT hRes = SafeArrayGetElement(pvarArr->parray, Indices, pvarVal);
if(hRes != S_OK) _com_issue_error(hRes);
}
---------------------------------
Konstantin
AlarIT developer