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. Passing a COM interface to an out of process COM object

Passing a COM interface to an out of process COM object

Scheduled Pinned Locked Moved COM
questionc++comsysadminhelp
7 Posts 5 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.
  • J Offline
    J Offline
    Jeremy Pullicino
    wrote on last edited by
    #1

    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."

    J S M 3 Replies Last reply
    0
    • J Jeremy Pullicino

      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."

      J Offline
      J Offline
      John Smith
      wrote on last edited by
      #2

      If you are using MFC, you can use LPDISPATCH as the type in your odl file. Use this to pass your other COM Interface

      1 Reply Last reply
      0
      • J Jeremy Pullicino

        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."

        S Offline
        S Offline
        Shadi Al Kahwaji
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • J Jeremy Pullicino

          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."

          M Offline
          M Offline
          Marc Britten
          wrote on last edited by
          #4

          pass it as an IUnknown* then queryinterface for IMyObject when you get it.

          J 1 Reply Last reply
          0
          • M Marc Britten

            pass it as an IUnknown* then queryinterface for IMyObject when you get it.

            J Offline
            J Offline
            Jeremy Pullicino
            wrote on last edited by
            #5

            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."

            J 1 Reply Last reply
            0
            • J Jeremy Pullicino

              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."

              J Offline
              J Offline
              Jeremy Pullicino
              wrote on last edited by
              #6

              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."

              L 1 Reply Last reply
              0
              • J Jeremy Pullicino

                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."

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

                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.

                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