Trouble filling the SafeArray with double datatype values using 'SafeArrayPutElement'. I get E_INVALIDARG error.
*pEventCode is my safearray... dEventCd is the 'double' value...I want to insert the dEventCd values to my *pEventCode safearray one by one when (bPriv) is true... Please help

HRESULT hr = SafeArrayDestroyData(*pEventCode);

for(INT_PTR count(0); count < nEventCnt; ++count) 
    mapEventCds.GetNextAssoc(pos, dEventCd, bPriv); 

    if (bPriv) 
        hr = SafeArrayPutElement(*pEventCode, &iEventCdIdx, &dEventCd);

The error code you're getting indicates that one of the arguments isn't valid. Here's the msdn article that outlines all the pariculars.

I have read that. It requires a VARIANT element to be added. I have a double datatype value.. Is there a way I insert this double value?