
passing Array of Strings between a C/C++ DLL and VB
Quote:
> Thanks for the response Larry.
You're welcome.
Quote:
> One more quick question - are
> you suggesting that I allocate the array within the C/C++ Dll?
Yes.
Quote:
> If so, then i would have to make sure to free up the memory with
> another call to the dll - correct?
No. One of several advantages to doing it per my
suggestion is that you are using the same protocol
that VB itself uses. If you pass a SAFEARRAY **,
(which is the equivalent of a ByRef array in VB),
all allocation issues will be properly handled on
the VB side as long as you do your part on the DLL
side. That means, for example, that you free any
array that comes in if you have to reform it. The
array will be treated by VB just as one of its own
because that's what it will be. This means it will
be freed as appropriate.
Quote:
> I just want to make sure that whatever method I use to solve
> this issue is one that is generally accepted.
What I suggested is *the* way accepted by VB and
what it uses internally. Take a look at the
routines SafeArrayCreate(), SafeArrayDestroy(),
SysAllocString(), SysFreeString() and associated
routines.
Quote:
> thanks
Sure.
--
Larry Brasfield
Above opinions may be mine alone.