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. Help! Passing custom objects back and forth in COM

Help! Passing custom objects back and forth in COM

Scheduled Pinned Locked Moved COM
c++helpcomtutorialquestion
4 Posts 4 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.
  • R Offline
    R Offline
    Ron Olson
    wrote on last edited by
    #1

    Hey all- I've used ATL/COM quite a bit, but I've always designed my apps from scratch to take parameters and return values using the standard types (strings, numbers, etc). Ok, now I have to wrap some functionality from a big app into a com object, and in a number of cases a pointer to a class is returned from a function, or a function takes a class or some other user defined type, etc. Basically, the job is ripping out some classes from a big mfc app and putting it in a com object. Great, but how to do it? I can't pass a custom object around (or I haven't been able to pass it using a VARIANT), and the amount of time to rewrite everything to be COM-friendly would far exceed the allotted time. I've searched Google as well as here and CodeGuru, but find nothing about this particular problem. I believe you can do it with straight DLLs, so I don't know why you couldn't also do it with com objects as well. Thanks for any info, Ron

    B L 2 Replies Last reply
    0
    • R Ron Olson

      Hey all- I've used ATL/COM quite a bit, but I've always designed my apps from scratch to take parameters and return values using the standard types (strings, numbers, etc). Ok, now I have to wrap some functionality from a big app into a com object, and in a number of cases a pointer to a class is returned from a function, or a function takes a class or some other user defined type, etc. Basically, the job is ripping out some classes from a big mfc app and putting it in a com object. Great, but how to do it? I can't pass a custom object around (or I haven't been able to pass it using a VARIANT), and the amount of time to rewrite everything to be COM-friendly would far exceed the allotted time. I've searched Google as well as here and CodeGuru, but find nothing about this particular problem. I believe you can do it with straight DLLs, so I don't know why you couldn't also do it with com objects as well. Thanks for any info, Ron

      B Offline
      B Offline
      Bill Wilson
      wrote on last edited by
      #2

      I'm having the same problem... I finally gave up and separated the attributes into individual arguments. Ther must be some way to get the structure into a VARIANT. The last thing (I didn't try) was to put it into a SAFEARRAY of object pointers... If you find out how, please let me know. Thanks for the help, Bill

      G 1 Reply Last reply
      0
      • B Bill Wilson

        I'm having the same problem... I finally gave up and separated the attributes into individual arguments. Ther must be some way to get the structure into a VARIANT. The last thing (I didn't try) was to put it into a SAFEARRAY of object pointers... If you find out how, please let me know. Thanks for the help, Bill

        G Offline
        G Offline
        Ganesh Ramaswamy
        wrote on last edited by
        #3

        In COM, as far as i know, custom data types/objects can be passed as structures. This can be passed from server to client. But, if u really want to use the functionality of class, pass the interfaces from server to client and using that call the class functions and make those funtions also return interface pointers, using which again u can access the class. But, all these are theoriticall speaking and if needed may be i can create a sample for it. But i dont know ur requirements. Ganesh.M.Ramaswamy

        1 Reply Last reply
        0
        • R Ron Olson

          Hey all- I've used ATL/COM quite a bit, but I've always designed my apps from scratch to take parameters and return values using the standard types (strings, numbers, etc). Ok, now I have to wrap some functionality from a big app into a com object, and in a number of cases a pointer to a class is returned from a function, or a function takes a class or some other user defined type, etc. Basically, the job is ripping out some classes from a big mfc app and putting it in a com object. Great, but how to do it? I can't pass a custom object around (or I haven't been able to pass it using a VARIANT), and the amount of time to rewrite everything to be COM-friendly would far exceed the allotted time. I've searched Google as well as here and CodeGuru, but find nothing about this particular problem. I believe you can do it with straight DLLs, so I don't know why you couldn't also do it with com objects as well. Thanks for any info, Ron

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

          The definition of the datatype has to be added to the interface and the pointer should be of that datatype. Then you can pass custom datatypes. In MSDN index, type in "struct", it will bring up one for IDL/MIDL. You should be able to take it up from there. - Thomas

          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