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. How to return a vector or an array?

How to return a vector or an array?

Scheduled Pinned Locked Moved COM
c++comgraphicsdata-structurestutorial
8 Posts 4 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

    Hello all, I'm now wrting an IDL file for COM. if I want to return a vector of string, what can I do? The method that I want is following in c++ vector Function(); As far as I know, a string can be BSTR in IDL, so what in IDL corresponds to a vector or an array in C++? Thank you very much!

    L 1 Reply Last reply
    0
    • T tpndtbk

      Hello all, I'm now wrting an IDL file for COM. if I want to return a vector of string, what can I do? The method that I want is following in c++ vector Function(); As far as I know, a string can be BSTR in IDL, so what in IDL corresponds to a vector or an array in C++? Thank you very much!

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Try SAFEARRAY. But I think it is not recognized by MIDL compiler. Let me know if you find some other way of using arrays in IDL that MIDL recognizes.* * *

      Have a great day ahead! Regards, Sohail Kadiwala (My Blog - http://blogs.wdevs.com/sohail/[^])

      S 1 Reply Last reply
      0
      • L Lost User

        Try SAFEARRAY. But I think it is not recognized by MIDL compiler. Let me know if you find some other way of using arrays in IDL that MIDL recognizes.* * *

        Have a great day ahead! Regards, Sohail Kadiwala (My Blog - http://blogs.wdevs.com/sohail/[^])

        S Offline
        S Offline
        Steve S
        wrote on last edited by
        #3

        SAFEARRAY(BSTR) should be recognised and understood perfectly well by MIDL. I've worked on projects that made heavy use of these things, and stuff like SAFEARRAYs of user defined types Steve S Developer for hire

        L A 2 Replies Last reply
        0
        • S Steve S

          SAFEARRAY(BSTR) should be recognised and understood perfectly well by MIDL. I've worked on projects that made heavy use of these things, and stuff like SAFEARRAYs of user defined types Steve S Developer for hire

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Hi Steve, the MIDL compiler doesn't understand SAFEARRAY (I read it in some article). Can you lead me to some good resource/URL where more on this is shown?* * *

          Have a great day ahead! Regards, Sohail Kadiwala (My Blog - http://blogs.wdevs.com/sohail/[^])

          S 1 Reply Last reply
          0
          • S Steve S

            SAFEARRAY(BSTR) should be recognised and understood perfectly well by MIDL. I've worked on projects that made heavy use of these things, and stuff like SAFEARRAYs of user defined types Steve S Developer for hire

            A Offline
            A Offline
            Akshay Dave
            wrote on last edited by
            #5

            Hi Steve, I am in very much need of Safearray related concepts and methodologies and its use in MIDL file.because I need much use of it too pass large values from COM Dll to VB in meterological projects and M/c related projects.Plz send me some codes and some URL where I can get get proper conceptual knowledge of SAFEARRAY with code.I'm currently facing difficulty in Passing SAFEARRAY from ATL/COM DLL to VB in an Event.So please help me.I am a memeber of this group by name Akshay Dave.My mail id is avd9683@rediffmail.com, akshayd@eqqu.com. Awaiting eagerly 4 ur reply. Akshay Dave Akshay Dave

            L S 2 Replies Last reply
            0
            • L Lost User

              Hi Steve, the MIDL compiler doesn't understand SAFEARRAY (I read it in some article). Can you lead me to some good resource/URL where more on this is shown?* * *

              Have a great day ahead! Regards, Sohail Kadiwala (My Blog - http://blogs.wdevs.com/sohail/[^])

              S Offline
              S Offline
              Steve S
              wrote on last edited by
              #6

              Good resource would be "Essential IDL" written by Martin Gudgin, or "Essential COM" by Don Box. If you write HRESULT getList([out]SAFEARRAY(BSTR)*ppsa); in your IDL for the interface method, in your C++ you have STDMETHOD(getList)(SAFEARRAY**ppsa); as a definition, and STDMETHODIMP class::getList(SAFEARRAY**ppsa) { ... } as your implementation. In IDL, the array type is known (and can be a simple type, like 'long' or 'DATE', or even a user defined type (structure)). One issue is that if you're using the MIDL that came with VC++6, you might want to upgrade by downloading the Platform SDK. In your implementation, you need to create a SAFEARRAY, and fill in the pointer properly. There must be loads of code out there, google for "SAFEARRAY IDL SOURCE" or look here[^] for some examples of more complicated stuff... Steve S Developer for hire

              1 Reply Last reply
              0
              • A Akshay Dave

                Hi Steve, I am in very much need of Safearray related concepts and methodologies and its use in MIDL file.because I need much use of it too pass large values from COM Dll to VB in meterological projects and M/c related projects.Plz send me some codes and some URL where I can get get proper conceptual knowledge of SAFEARRAY with code.I'm currently facing difficulty in Passing SAFEARRAY from ATL/COM DLL to VB in an Event.So please help me.I am a memeber of this group by name Akshay Dave.My mail id is avd9683@rediffmail.com, akshayd@eqqu.com. Awaiting eagerly 4 ur reply. Akshay Dave Akshay Dave

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                Hi Akshay, Did u check the link Steve has given? http://www.mvps.org/vcfaq/com/4.htm[^] Its got some good neat stuff on it. Also Check on MSDN for SAFEARRAY.* * *

                Have a great day ahead! Regards, Sohail Kadiwala (My Blog - http://blogs.wdevs.com/sohail/[^])

                1 Reply Last reply
                0
                • A Akshay Dave

                  Hi Steve, I am in very much need of Safearray related concepts and methodologies and its use in MIDL file.because I need much use of it too pass large values from COM Dll to VB in meterological projects and M/c related projects.Plz send me some codes and some URL where I can get get proper conceptual knowledge of SAFEARRAY with code.I'm currently facing difficulty in Passing SAFEARRAY from ATL/COM DLL to VB in an Event.So please help me.I am a memeber of this group by name Akshay Dave.My mail id is avd9683@rediffmail.com, akshayd@eqqu.com. Awaiting eagerly 4 ur reply. Akshay Dave Akshay Dave

                  S Offline
                  S Offline
                  Steve S
                  wrote on last edited by
                  #8

                  You need to read either (or both) Essential IDL and Essential COM, or at a minimum, look for examples on MSDN and other sites (like this one) which use SAFEARRAYs. Google for SAFEARRAY SAMPLE or SAFEARRAY SOURCE which should help you get started. Alternatively, my rates for training (if you're UK based) are quite competitive :) Steve S Developer for hire

                  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