How to pass an array from COM back to Visual Basic?
See the question and my original answer on StackOverflowYou were not far from the solution. With your getArrayData
definition, you can simply call it like this from VB:
Dim b As Variant
Dim result As Integer
result = mInterface.getArrayData(b)
However, you can also define it as a property in .idl, like this:
[id(2), propget] // note propget
HRESULT ArrayData([out, retval] VARIANT* pVal);
like this in C/C++ (you don't need result since the array is self descriptive):
HRESULT STDMETHODCALLTYPE get_ArrayData(VARIANT* pVal) ...
and like this in VB:
Dim a As Variant
a = mInterface.ArrayData
Here are the VB watches for a & b variants:
PS: VB(6) is old, but COM is not, it's still used everywhere in Windows :-)