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 Object Pointers In COM

Passing Object Pointers In COM

Scheduled Pinned Locked Moved COM
helpc++comdocker
12 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.
  • A Adrian Metcalfe

    HELP ! I am VERY new to COM (3 days experience) and I want to do something which may sound a bit odd. I wish to take a pointer to a C++ object from one application and pass it via COM to another C++ application. The only stuff I have found on doing this involves serializing the objet to a CMemFile and passing it as a string. The Object I wish to pass is a container and I do not wish to make everything it holds serializable, problem. If anybody can help me it would be nice. Thanks

    P Offline
    P Offline
    Peter Zajac
    wrote on last edited by
    #3

    On the other hand it would be better to create a COM wraper for the object that you are passing. And than just pass the interface pointer.

    A 1 Reply Last reply
    0
    • P Peter Zajac

      You can try to get pointer to your object and then pass it to your COM object as LONG. That way your COM object will know the memory location of the object you are passing. Peter

      A Offline
      A Offline
      Adrian Metcalfe
      wrote on last edited by
      #4

      I have tried passing the pointer to the object as long. When I do this it does not appear (when debugging the COM)to have the same value it had in the app which created it. Also I could not get the long value back into the second app, it had a different value. Puzzled !

      L 1 Reply Last reply
      0
      • P Peter Zajac

        On the other hand it would be better to create a COM wraper for the object that you are passing. And than just pass the interface pointer.

        A Offline
        A Offline
        Adrian Metcalfe
        wrote on last edited by
        #5

        How do I create a COM wrapper ? Remember I am very new to COM.

        1 Reply Last reply
        0
        • A Adrian Metcalfe

          HELP ! I am VERY new to COM (3 days experience) and I want to do something which may sound a bit odd. I wish to take a pointer to a C++ object from one application and pass it via COM to another C++ application. The only stuff I have found on doing this involves serializing the objet to a CMemFile and passing it as a string. The Object I wish to pass is a container and I do not wish to make everything it holds serializable, problem. If anybody can help me it would be nice. Thanks

          M Offline
          M Offline
          Michael Dunn
          wrote on last edited by
          #6

          >I wish to take a pointer to a C++ object from one application and pass it via COM to another C++ application. You cannot do this, COM or no COM. Each Win32 app has its own isolated memory space. A pointer in app A has no meaning if you pass it to app B. You'll need to use IPC (inter-process communication) techniques to pass data between apps. There are articles here at CP on doing this - give them a read. (You are sort-of on the right track with CMemFile, but CMemFile is not a memory-mapped file, which is the IPC mechanism you're thinking of.)

          1 Reply Last reply
          0
          • A Adrian Metcalfe

            I have tried passing the pointer to the object as long. When I do this it does not appear (when debugging the COM)to have the same value it had in the app which created it. Also I could not get the long value back into the second app, it had a different value. Puzzled !

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

            If your com is an exe the passing a pointer as long will not work since the com is in a diferent process and therefore the address in the long is not valid. Passing pointers as long will work only if your COM is a dll. (Don't forget to cast the pointer in both sides back to the structure it points to, before using it).

            1 Reply Last reply
            0
            • A Adrian Metcalfe

              HELP ! I am VERY new to COM (3 days experience) and I want to do something which may sound a bit odd. I wish to take a pointer to a C++ object from one application and pass it via COM to another C++ application. The only stuff I have found on doing this involves serializing the objet to a CMemFile and passing it as a string. The Object I wish to pass is a container and I do not wish to make everything it holds serializable, problem. If anybody can help me it would be nice. Thanks

              T Offline
              T Offline
              Todd Smith
              wrote on last edited by
              #8

              What exactly are you trying to do? What does this C++ do that separate applications need access to it? You might want to put the C++ object in a separate COM object and have it shared between processes.

              A 1 Reply Last reply
              0
              • T Todd Smith

                What exactly are you trying to do? What does this C++ do that separate applications need access to it? You might want to put the C++ object in a separate COM object and have it shared between processes.

                A Offline
                A Offline
                Adrian Metcalfe
                wrote on last edited by
                #9

                I am using one app to do an external equipment search (this takes a while) and store the objects it created (one per equipment present) in a COM server. I want many other applications on the same machine to be able to query the COM server to get pointers to the objects. So Equipment search app -> COM server COM Server -> Testing App 1 COM Server -> Testing App 2 etc I do not want to have to go through all my equipment classes and make them serializable. Thanks :confused: :confused:

                T 2 Replies Last reply
                0
                • A Adrian Metcalfe

                  I am using one app to do an external equipment search (this takes a while) and store the objects it created (one per equipment present) in a COM server. I want many other applications on the same machine to be able to query the COM server to get pointers to the objects. So Equipment search app -> COM server COM Server -> Testing App 1 COM Server -> Testing App 2 etc I do not want to have to go through all my equipment classes and make them serializable. Thanks :confused: :confused:

                  T Offline
                  T Offline
                  Todd Smith
                  wrote on last edited by
                  #10

                  Then I would wrap your C++ class in a COM object. You can pass an interface pointer from your server to the clients so they may access the C++/COM object.

                  1 Reply Last reply
                  0
                  • A Adrian Metcalfe

                    I am using one app to do an external equipment search (this takes a while) and store the objects it created (one per equipment present) in a COM server. I want many other applications on the same machine to be able to query the COM server to get pointers to the objects. So Equipment search app -> COM server COM Server -> Testing App 1 COM Server -> Testing App 2 etc I do not want to have to go through all my equipment classes and make them serializable. Thanks :confused: :confused:

                    T Offline
                    T Offline
                    Todd Smith
                    wrote on last edited by
                    #11

                    Then I would wrap your C++ class in a COM object. You can pass an interface pointer from your server to the clients so they may access the C++/COM object.

                    A 1 Reply Last reply
                    0
                    • T Todd Smith

                      Then I would wrap your C++ class in a COM object. You can pass an interface pointer from your server to the clients so they may access the C++/COM object.

                      A Offline
                      A Offline
                      Adrian Metcalfe
                      wrote on last edited by
                      #12

                      Which class, the container or each of the equipment classes (many different types) ?

                      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