extern "C" DCPP_API long xlat_SafeArray(SAFEARRAY * *psaArray, double* pd) { return codes: 0 - Success > 0 - Failure ================================================================ = */ { long lElements; // number of elements in the array long iCount; HRESULT lResult; // return code for OLE functions double* pArrayElements; // pointer to the elements of the array // initializing the output *pd = 0; // checking if it is an one-dimensional array if ((*psaArray)->cDims != 1) return(1); // checking if it is an array of doubles(long longs?) if ((*psaArray)->cbElements != 8) return(2); // how many elements are there in the array lElements = (*psaArray)->rgsabound[0].cElements; // locking the array before using its elements lResult = SafeArrayLock(*psaArray); if (lResult)return(3); // using the array pArrayElements = (double*)(*psaArray)->pvData; pArrayElements[3] = M_PI * pArrayElements[0] * pArrayElements[0] * pArrayElements[1] * pArrayElements[2] / 4.0; *pd= pArrayElements[3]; // releasing the array lResult = SafeArrayUnlock(*psaArray); if (lResult) return(4); // returning return(0); } };