Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Returning an array to VB through COM

The only array COM allows is a SAFEARRAY which contains VARIANT as described
in the example.

The good thing is that each one of those VARIANT variables can hold a BSTR
(COM string) to be returned ...

P.S. Remember to SysAllocString() your string when you put it in the VARIANT.

"sean" <sean@schof.com> wrote:
>
>I'm a COM newbie and I need help with a function that returns a String array
>to VB from a C++ DLL. There is an example of how to do this in the "Beginning
>ATL COM" book but only for an array of VARIANTS. If anyone could provide
>me with a simple example with the IDL as well as the C++ implemenation ,
>I'd be very grateful.
>
>Thanks,
>
>- sean
[783 byte] By [Peggy Young] at [2007-11-10 12:51:39]
# 1 Re: Returning an array to VB through COM
This subject is addressed in the following MSDN articles: Q194609 and Q171583.
The document VB4DLL.TXT also has very helpful information. It works, but
it's not a trivial subject.
BZ

"Peggy Young" <peggy_young@daytimer.com> wrote:
>
>The only array COM allows is a SAFEARRAY which contains VARIANT as described
>in the example.
>
>The good thing is that each one of those VARIANT variables can hold a BSTR
>(COM string) to be returned ...
>
>P.S. Remember to SysAllocString() your string when you put it in the VARIANT.
>
>"sean" <sean@schof.com> wrote:
>>
>>I'm a COM newbie and I need help with a function that returns a String
array
>>to VB from a C++ DLL. There is an example of how to do this in the "Beginning
>>ATL COM" book but only for an array of VARIANTS. If anyone could provide
>>me with a simple example with the IDL as well as the C++ implemenation
,
>>I'd be very grateful.
>>
>>Thanks,
>>
>>- sean
>
bill zemek at 2007-11-11 20:40:53 >