Passing a COM interface to an out of process COM object
-
Please help! I am getting desperate. X| Hello, here is my situation: I have a normal C++ program that has an instance of a COM object (my own), IMyObject I have another out-of-process COM server, which exposes a COM object IMyOtherObject. IMyOtherObject is held by my C++ program. So, I end up with this in my C++ program: void main() { IMyObject IMyOtherObject } Now, IMyOtherObject needs to use IMyObject. How do I pass IMyObject to IMyOtherObject? Is this possible? where should I look? HELP Jeremy. "Hey man, Taliban, Tali me Banana."
-
Please help! I am getting desperate. X| Hello, here is my situation: I have a normal C++ program that has an instance of a COM object (my own), IMyObject I have another out-of-process COM server, which exposes a COM object IMyOtherObject. IMyOtherObject is held by my C++ program. So, I end up with this in my C++ program: void main() { IMyObject IMyOtherObject } Now, IMyOtherObject needs to use IMyObject. How do I pass IMyObject to IMyOtherObject? Is this possible? where should I look? HELP Jeremy. "Hey man, Taliban, Tali me Banana."
If you are using MFC, you can use LPDISPATCH as the type in your odl file. Use this to pass your other COM Interface
-
Please help! I am getting desperate. X| Hello, here is my situation: I have a normal C++ program that has an instance of a COM object (my own), IMyObject I have another out-of-process COM server, which exposes a COM object IMyOtherObject. IMyOtherObject is held by my C++ program. So, I end up with this in my C++ program: void main() { IMyObject IMyOtherObject } Now, IMyOtherObject needs to use IMyObject. How do I pass IMyObject to IMyOtherObject? Is this possible? where should I look? HELP Jeremy. "Hey man, Taliban, Tali me Banana."
Hi, If you cannot send the Interface becuase you don't find a data type to send it, then there is no problem. If you want to send IMyObject interface to IMyOtherObject interface, you have to define method to do this in IMyOtherObject like this: STDMETHOD(SetIMyObjectInterface)(IMyObject *pMyObject); The problem here that you might compile this using the .h and .c of the IMyObject, but you will face a problem inside the .IDL file, which is IMyObject is undeclared. To solve this problem, move IMyOtherObject section in the IDL to the type library body: library MYLIBLib { .... //Don't forget to import IMyObject type library here to define the IMyObject Interface interface IMyOtherObject : IDispatch { SetIMyObjectInterface(IMyObject *pMyObject); } .... } I guess this would help you to pass an com interface to another com component. If this does not answer your question, please, re-phrase your question. Regards, ShadiK. Shadi Al-Kahwaji
-
Please help! I am getting desperate. X| Hello, here is my situation: I have a normal C++ program that has an instance of a COM object (my own), IMyObject I have another out-of-process COM server, which exposes a COM object IMyOtherObject. IMyOtherObject is held by my C++ program. So, I end up with this in my C++ program: void main() { IMyObject IMyOtherObject } Now, IMyOtherObject needs to use IMyObject. How do I pass IMyObject to IMyOtherObject? Is this possible? where should I look? HELP Jeremy. "Hey man, Taliban, Tali me Banana."
pass it as an IUnknown* then queryinterface for IMyObject when you get it.
-
pass it as an IUnknown* then queryinterface for IMyObject when you get it.
I tied this (I am trying everything!) Its the best results I got so far. I pass the IUnkown* , and on the other side I queryinterface. before passing IMyObject, I do this: myObj.QueryInterface(IID_IUnknown,&pUnk); Then I pass pUnk to IMyOtherObject. This is how I do the queryinterface in IMyOtherObject: pUnk->QueryInterface(__uuidof(IMyObj),reinterpret_cast _void**> &pMyObj)) However, when I queryinterface I get the error "The interface is unknown." Am I doing it right? Jeremy. "Hey man, Taliban, Tali me Banana."
-
I tied this (I am trying everything!) Its the best results I got so far. I pass the IUnkown* , and on the other side I queryinterface. before passing IMyObject, I do this: myObj.QueryInterface(IID_IUnknown,&pUnk); Then I pass pUnk to IMyOtherObject. This is how I do the queryinterface in IMyOtherObject: pUnk->QueryInterface(__uuidof(IMyObj),reinterpret_cast _void**> &pMyObj)) However, when I queryinterface I get the error "The interface is unknown." Am I doing it right? Jeremy. "Hey man, Taliban, Tali me Banana."
OK. I did some more research: (I bought Inside Distributed COM - Guy Eddon, Henry Eddon, MS Press). A Very good book. I came across a section: Marshalling Interface Pointers. It says that taking an IMyObject interface pointer and return it to a client in another process is not possible. He says: "What constitutes a valid interface pointer in one apartment is complete gibberish in another." I think will have to re-create the V-table and do some other stuff. Jeremy. "Hey man, Taliban, Tali me Banana."
-
OK. I did some more research: (I bought Inside Distributed COM - Guy Eddon, Henry Eddon, MS Press). A Very good book. I came across a section: Marshalling Interface Pointers. It says that taking an IMyObject interface pointer and return it to a client in another process is not possible. He says: "What constitutes a valid interface pointer in one apartment is complete gibberish in another." I think will have to re-create the V-table and do some other stuff. Jeremy. "Hey man, Taliban, Tali me Banana."
You can generate a proxy stub DLL which will allow the interface to be marshalled. It is indeed very possible to pass interface pointers across, and it is very easy. I do it all the time. For the answers to this, and pretty much any other question about COM, I would HIGHLY recommend Essential COM by Don Box as THE book on COM.