Returning Class Pointer From ATL component.. [modified]
-
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
-
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
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?
-
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?
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.
-
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.
Is there anything preventing you from creating and exposing another COM Interface that returns the values you are interested in?
-
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.
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
-
Is there anything preventing you from creating and exposing another COM Interface that returns the values you are interested in?
Now we're talking.
Steve