News:

When replying to a specific statement be sure to quote the previous post.

Main Menu

Can I use a COleSafeArray as a property? I can add it but I can't get it back.

Started by jerry.simington, December 24, 2014, 09:44:08 AM

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

jerry.simington

In the following code "res = pData->get_Value(0,&varValue);" returns E_FAIL.


HRESULT SetProperty (IGraphic* pGraphic, CString Name, COleSafeArray value, COleVariant ReadOnly )
{
   if (pGraphic==(IGraphic*)NULL) return E_POINTER;
   Properties* pProp = NULL;
   HRESULT res = pGraphic->get_Properties(&pProp);
   if (SUCCEEDED(res))
   {
      Property* pData = NULL;
      res = pProp->get_Item(COleVariant(Name),&pData);
      if (SUCCEEDED(res))
      {
         pData->put_Value(0, value);
         pData->Release();
         return res;
      }
      res = pProp->Add(Name.AllocSysString(),&value,&ReadOnly,varMissed,&pData);
      if (SUCCEEDED(res))
      {
         // test
         COleSafeArray varValue;
         res = pData->get_Value(0,&varValue);
         pData->Release();
      }
      pProp->Release();
   }
   return res;
}