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. ATL / WTL / STL
  4. Returning Class Pointer From ATL component.. [modified]

Returning Class Pointer From ATL component.. [modified]

Scheduled Pinned Locked Moved ATL / WTL / STL
c++helplearning
6 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.
  • M Offline
    M Offline
    Mahesh Kulkarni
    wrote on last edited by
    #1

    Hi All, I want to return a Class pointer from ATL Dll.Currently I am trying method using IDispatch * but giving problem, return pointer is invalid . Please give me a solution for this. Thanks in Advance.

    The secret of life is not enjoyment but education through experience. - Swami Vivekananda.

    -- modified at 8:30 Monday 24th July, 2006

    S 1 Reply Last reply
    0
    • M Mahesh Kulkarni

      Hi All, I want to return a Class pointer from ATL Dll.Currently I am trying method using IDispatch * but giving problem, return pointer is invalid . Please give me a solution for this. Thanks in Advance.

      The secret of life is not enjoyment but education through experience. - Swami Vivekananda.

      -- modified at 8:30 Monday 24th July, 2006

      S Offline
      S Offline
      Stephen Hewitt
      wrote on last edited by
      #2

      You don't return class pointers in COM: It violates the whole concept of COM. COM components are meant to be (programming) language neutral so you can't be returning classes from COM objects: What good is a C++ class to VB, for example? Can you be more specific with what (exactly) you're trying to achieve?

      M 1 Reply Last reply
      0
      • S Stephen Hewitt

        You don't return class pointers in COM: It violates the whole concept of COM. COM components are meant to be (programming) language neutral so you can't be returning classes from COM objects: What good is a C++ class to VB, for example? Can you be more specific with what (exactly) you're trying to achieve?

        M Offline
        M Offline
        Mahesh Kulkarni
        wrote on last edited by
        #3

        Thanks For the Reply. Details : I have used one class in COM Interface. This class gets manipulated in the com method. Further I need the class pointer so that I can access the values of that class which are modified by the COM. I want the pointer in the function from where I invoked the COM method.

        The secret of life is not enjoyment but education through experience. - Swami Vivekananda.

        J S 2 Replies Last reply
        0
        • M Mahesh Kulkarni

          Thanks For the Reply. Details : I have used one class in COM Interface. This class gets manipulated in the com method. Further I need the class pointer so that I can access the values of that class which are modified by the COM. I want the pointer in the function from where I invoked the COM method.

          The secret of life is not enjoyment but education through experience. - Swami Vivekananda.

          J Offline
          J Offline
          Justin Tay
          wrote on last edited by
          #4

          Is there anything preventing you from creating and exposing another COM Interface that returns the values you are interested in?

          S 1 Reply Last reply
          0
          • M Mahesh Kulkarni

            Thanks For the Reply. Details : I have used one class in COM Interface. This class gets manipulated in the com method. Further I need the class pointer so that I can access the values of that class which are modified by the COM. I want the pointer in the function from where I invoked the COM method.

            The secret of life is not enjoyment but education through experience. - Swami Vivekananda.

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

            No you don't. A COM interface should provide all the functionality, which may well include accessors for properties. If you start handing out raw C++ class pointers, it is no longer COM, no longer marshallable, remotable, or usable by anything other than a VC++ client, and possibly not even that if you later switch to a different version of VC++. An interface is not a class. A class may implement one or more interfaces (typically IUnknown, sometimes IDispatch, and one or more interfaces derived from them), but an interface is not a pointer to an object, nor should it be treated as one. This means no access via an interface to member data, and no casting the interface to something else directly. You need to read (or re-read) Don Box's "Essential COM", plus there is an MSDN article which essentially describes the process of going from a C++ class to COM interfaces in design terms (here[^])

            Steve S Developer for hire

            1 Reply Last reply
            0
            • J Justin Tay

              Is there anything preventing you from creating and exposing another COM Interface that returns the values you are interested in?

              S Offline
              S Offline
              Stephen Hewitt
              wrote on last edited by
              #6

              Now we're talking.

              Steve

              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