Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. COM
  4. SAFEARRAY(IDispatch*) problem in matlab

SAFEARRAY(IDispatch*) problem in matlab

Scheduled Pinned Locked Moved COM
helpc++comquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tpndtbk
    wrote on last edited by
    #1

    Hi all, I create a COM in VC++. It has a funtion that returns a SAFEARRAY (IDispatch*) . if I use this Com in c++, it works fine, but if I call this function in matlab, it causes problem. Does any one have experience on it? Thank you for any help. Tran Phuong Nga

    A 1 Reply Last reply
    0
    • T tpndtbk

      Hi all, I create a COM in VC++. It has a funtion that returns a SAFEARRAY (IDispatch*) . if I use this Com in c++, it works fine, but if I call this function in matlab, it causes problem. Does any one have experience on it? Thank you for any help. Tran Phuong Nga

      A Offline
      A Offline
      Anonymous
      wrote on last edited by
      #2

      Try wrapping it into a VARIANT instead. I.e. HRESULT MyMethod([out,retval] VARIANT * pVar); And the variant is initialized like this (roughly): VARIANT l_var; VariantInit(&l_var); l_var.vt = VT_DISPATCH | VT_ARRAY; l_var.parray = your_safe_array;

      T 1 Reply Last reply
      0
      • A Anonymous

        Try wrapping it into a VARIANT instead. I.e. HRESULT MyMethod([out,retval] VARIANT * pVar); And the variant is initialized like this (roughly): VARIANT l_var; VariantInit(&l_var); l_var.vt = VT_DISPATCH | VT_ARRAY; l_var.parray = your_safe_array;

        T Offline
        T Offline
        tpndtbk
        wrote on last edited by
        #3

        Hi, thank you for your help. But the problem comes from the following code: SafeArrayCreateVector(VT_DISPATCH, 0, length);. If I hide this code, no problem any more. If the code is SafeArrayCreateVector(VT_INT, 0, length); or SafeArrayCreateVector(VT_BSTR, 0, length);.., no problem. So eventhough I wrap the return value into VARIANT type, I still have to call SafeArrayCreateVector(VT_DISPATCH, 0, length);, then the problem is still there. Do you know how to solve it, or is there any other ways to create a vector of IDispatch*? Thank you. Nga

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups