How does one return a local CComSafeArray to a LPSAFEARRAY output parameter?

后端 未结 3 2207
花落未央
花落未央 2021-02-20 05:35

I have a COM function that should return a SafeArray via a LPSAFEARRAY* out parameter. The function creates the SafeArray using ATL\'s CComSafeArray te

3条回答
  •  离开以前
    2021-02-20 05:53

    The problem is that you set the receiving CComSafeArray's internal pointer directly. Use the Attach() method to attach an existing SAFEARRAY to a CComSafeArray:

    LPSAFEARRAY ar;
    foo(&ar);
    CComSafeArray sa;
    sa.Attach(ar);
    

提交回复
热议问题