RichEdit控件插入图片功能
一调用OleCreateStaticFromData内存就飙升,
这个要如何释放,在哪释放???
或者有什么替代接口

解决方案 »

  1.   

    OleCreateStaticFromData returns a COM pointer which you pass to the Rich Edit control. This COM pointer has had an AddRef applied to it, so you must call Release once you have passed it to the control, to signify that you no longer will be accessing it directly. The control will also do a Release when it is destroyed which should result in the COM object being deleted.You might also store the returned pointer in a smart pointer class _com_ptr_t or CComPtr and it will Release it automatically.
      

  2.   

    HRESULT OleCreateStaticFromData(
      _In_   LPDATAOBJECT pSrcDataObj,
      _In_   REFIID iid,
      _In_   DWORD renderopt,
      _In_   LPFORMATETC pFormatEtc,
      _In_   LPOLECLIENTSITE pClientSite,
      _In_   LPSTORAGE pStg,
      _Out_  LPVOID *ppvObj
    );The pSrcDataObject is still valid after OleCreateStaticFromData returns. It is the caller's responsibility to free pSrcDataObject — OLE does not release it.