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