COM Collections
Hello,
I was wondering if I have a COM server that one of the interfaces I implemented I would like it to return a collection of string like a CStringArray, can I use a reference to a CStringArray& as a [out,retval] param or is there a COM type that I can use?
Thanks in advance.
# 1 Re: COM Collections
A number of solutions:
1. Define and implement your own IStringArray interface.
2. Use a SAFEARRAY wrapped in a VARIANT
3. Use BSTR* and the size_is and length_is attribute.
Note that option 1 and 2 are the only VB compatible options.
Do _not_ expose your C++ classes in the COM interface. That is breaking COM rules and only bad things comes from that.
Hope this helps
# 2 Re: COM Collections
Thanks for your respone,
option 2- : Can you give me a quick example of wrapping a safearray as a variant and decoding at the client end.
ie: what do I pass from the client end and what does the com sends back?
Thanks again