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

lResult=SafeArrayUnlock(*pEventCode); 
HRESULT hr = SafeArrayDestroyData(*pEventCode);

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

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

Recommended Answers

All 2 Replies

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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.