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. Query Interface from Another Interface of Same Com Server

Query Interface from Another Interface of Same Com Server

Scheduled Pinned Locked Moved COM
c++databasecomsysadminquestion
5 Posts 2 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.
  • G Offline
    G Offline
    georgekjolly
    wrote on last edited by
    #1

    Hai all, I have two ATL Objects in my COM Server. Their interfaces are 1) IFirstIFC 2) ISecondIFC In my client programme I have imported the type library and using code below obtained the COM Object of IFirstIFC IFirstIFCPtr fIF; fIF.CreateInstance(__uuidof(FirstIFC)); Now my task is to obtain the COM Object of ISecondIFC. My Question is , Is there any method for Obtaining the Interface Pointer of ISecondFC by not calling again CreateInstance for that Interface. That is by avoiding this Code ISecondIFCPtr sIF; sIF.CreateInstance(__uuidof(SecondIFC)); That is,since both Interfaces are residing in the same COM Server, Can I get the Interface Pointer of ISecondFC through IFirstIFC. Thanks George

    R 1 Reply Last reply
    0
    • G georgekjolly

      Hai all, I have two ATL Objects in my COM Server. Their interfaces are 1) IFirstIFC 2) ISecondIFC In my client programme I have imported the type library and using code below obtained the COM Object of IFirstIFC IFirstIFCPtr fIF; fIF.CreateInstance(__uuidof(FirstIFC)); Now my task is to obtain the COM Object of ISecondIFC. My Question is , Is there any method for Obtaining the Interface Pointer of ISecondFC by not calling again CreateInstance for that Interface. That is by avoiding this Code ISecondIFCPtr sIF; sIF.CreateInstance(__uuidof(SecondIFC)); That is,since both Interfaces are residing in the same COM Server, Can I get the Interface Pointer of ISecondFC through IFirstIFC. Thanks George

      R Offline
      R Offline
      Roger Stoltz
      wrote on last edited by
      #2

      :confused::confused: A COM server is a COM object. This means that you actually have two servers. They may be located in the same file, but that's another thing. You cannot get an interface to an object without creating it. My suggestion: You could have the first server implement an interface method that will create the second server and by that you can avoid calling CreateInstance() from your client, but you would still have to call CreateInstance() from your first server in order to create the second one.


      "It's supposed to be hard, otherwise anybody could do it!" - selfquote
      "High speed never compensates for wrong direction!" - unknown

      G 1 Reply Last reply
      0
      • R Roger Stoltz

        :confused::confused: A COM server is a COM object. This means that you actually have two servers. They may be located in the same file, but that's another thing. You cannot get an interface to an object without creating it. My suggestion: You could have the first server implement an interface method that will create the second server and by that you can avoid calling CreateInstance() from your client, but you would still have to call CreateInstance() from your first server in order to create the second one.


        "It's supposed to be hard, otherwise anybody could do it!" - selfquote
        "High speed never compensates for wrong direction!" - unknown

        G Offline
        G Offline
        georgekjolly
        wrote on last edited by
        #3

        Hai Roger, I got it. Thank you very much. I have another Doubt. Is all COM communications(between COM Server and Client) happening through RPC. Bcz, I have seen RPC header files such as "rpc.h" "rpcndr.h" in both the COM Exe and COM Dll. Thanks George

        R 1 Reply Last reply
        0
        • G georgekjolly

          Hai Roger, I got it. Thank you very much. I have another Doubt. Is all COM communications(between COM Server and Client) happening through RPC. Bcz, I have seen RPC header files such as "rpc.h" "rpcndr.h" in both the COM Exe and COM Dll. Thanks George

          R Offline
          R Offline
          Roger Stoltz
          wrote on last edited by
          #4

          georgekjolly wrote:

          Is all COM communications(between COM Server and Client) happening through RPC

          No. The most common way is to create an in-process-server running in the same thread, i.e. a single threaded apartment (STA). In this case every call to the server is exactly like an ordinary function call. Remote Procedure Call (RPC) will be used when you're marshalling interfaces between multiple threads. To get a deeper understanding of marshalling and RPC I suggest you read Lim Bio Liong's excellent article serie starting here[^].


          "It's supposed to be hard, otherwise anybody could do it!" - selfquote
          "High speed never compensates for wrong direction!" - unknown

          G 1 Reply Last reply
          0
          • R Roger Stoltz

            georgekjolly wrote:

            Is all COM communications(between COM Server and Client) happening through RPC

            No. The most common way is to create an in-process-server running in the same thread, i.e. a single threaded apartment (STA). In this case every call to the server is exactly like an ordinary function call. Remote Procedure Call (RPC) will be used when you're marshalling interfaces between multiple threads. To get a deeper understanding of marshalling and RPC I suggest you read Lim Bio Liong's excellent article serie starting here[^].


            "It's supposed to be hard, otherwise anybody could do it!" - selfquote
            "High speed never compensates for wrong direction!" - unknown

            G Offline
            G Offline
            georgekjolly
            wrote on last edited by
            #5

            Hi Sir, Thank you very much for your help. Regards and Thanks George K J

            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