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. How to use one instance of a COM object in different processes?

How to use one instance of a COM object in different processes?

Scheduled Pinned Locked Moved COM
tutorialcomquestion
7 Posts 4 Posters 1 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
    Jawid
    wrote on last edited by
    #1

    Hi everyone, I am not able to find a way how to use the only one (common) instance of my COM object from several processes. Here I see the only solution of multiple instances and that way I lose some of the pointers. Can anybody guide me how to do that? Thanks, Jawid

    L P J 4 Replies Last reply
    0
    • J Jawid

      Hi everyone, I am not able to find a way how to use the only one (common) instance of my COM object from several processes. Here I see the only solution of multiple instances and that way I lose some of the pointers. Can anybody guide me how to do that? Thanks, Jawid

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

      Have you tried using RegisterActiveObject, to put your object in the ROT? Then you can use GetActiveObject. Scot Brennecke Software Developer VC++ MVP

      L 1 Reply Last reply
      0
      • J Jawid

        Hi everyone, I am not able to find a way how to use the only one (common) instance of my COM object from several processes. Here I see the only solution of multiple instances and that way I lose some of the pointers. Can anybody guide me how to do that? Thanks, Jawid

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

        If you com object was developed using ATL then there is a macro you can use to make it a singleton, meaning only one instance of it will be created and shared between all clients. Im sorry but i can't remeber what the macro is, its something like ATL_DECLARE_SINGLETON. Have a poke around in the MSDN although i found it in one of the wrox atl books.

        1 Reply Last reply
        0
        • L Lost User

          Have you tried using RegisterActiveObject, to put your object in the ROT? Then you can use GetActiveObject. Scot Brennecke Software Developer VC++ MVP

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

          I found that macro : http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/vcoriATLMacrosAlphabeticalReference.asp The particular one is : DECLARE_CLASSFACTORY_SINGLETON Hope this helps.

          1 Reply Last reply
          0
          • J Jawid

            Hi everyone, I am not able to find a way how to use the only one (common) instance of my COM object from several processes. Here I see the only solution of multiple instances and that way I lose some of the pointers. Can anybody guide me how to do that? Thanks, Jawid

            P Offline
            P Offline
            Pedro Miranda
            wrote on last edited by
            #5

            Hi, I’m sorry but I did not fully understand your question? You want to use the some instance of a COM object in different processes or different threads in the same process? If you want to pass a pointer to a object to another thread in a running process you have to be aware of the COM Threading Model (Apartments) and Marshalling see http://www.codeguru.com/activex/COMApartments1.html and http://www.codeguru.com/activex/COMApartments2.html . . If you really want different processes to access the same COM object, then this last has to be implemented in a out-process (.exe) COM server having the class factory returning the same object every time a instance of that class is requested. Remember that using an out-process com server you’ll be linking whit a proxy/stub dll (Marshalling). http://www.codeguru.com/activex/MiniDcom.html I recommend you reading Essential COM (Don Box), ATL Internals (Brent Rector) and Learning DCOM (Thuan L. Thai)

            1 Reply Last reply
            0
            • J Jawid

              Hi everyone, I am not able to find a way how to use the only one (common) instance of my COM object from several processes. Here I see the only solution of multiple instances and that way I lose some of the pointers. Can anybody guide me how to do that? Thanks, Jawid

              J Offline
              J Offline
              Jawid
              wrote on last edited by
              #6

              Hi Guys, Thanks for great help. All of those advices seem very helpfull. I tried the solution with macro for singleton object and it works nice. Thanks,

              E 1 Reply Last reply
              0
              • J Jawid

                Hi Guys, Thanks for great help. All of those advices seem very helpfull. I tried the solution with macro for singleton object and it works nice. Thanks,

                E Offline
                E Offline
                Ed K
                wrote on last edited by
                #7

                Make sure that it is an exe service rather than a dll service. A dll singleton loads a different instance per app. An exe will have only one instance. ed The nice thing about egotists is that they don't talk about other people. Lucille Harper

                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