So far I've figured out how to pass Unicode strings, bSTRs, to and from a Euphoria DLL using a Typelib. What I can't figure out, thus far, is how to create and pass back an array of BSTRs.
The code I have thus far (along with include
s for EuCOM itself and parts of Win32lib):
global function REALARR()
sequence seq
atom psa
atom var
seq = { "cat","cow","wolverine" }
psa = create_safearray( seq, VT_BSTR )
make_variant( var, VT_ARRAY + VT_BSTR, psa )
return var
end function
Part of the typelib is:
[
helpstring("get an array of strings"),
entry("REALARR")
]
void __stdcall REALARR( [out,retval] VARIANT* res );
And the test code, in VB6 is:
...
Dim v() as String
V = REALARR()
...
So far all I've managed to get is an error '0' from the DLL. Any ideas? Anyone?
You should use the create_safearray()
function. It's documented (hidden?) under Utilities. Basically, put your BSTR pointers into a sequence and pass it to create_safearray()
:
sequence s, bstrs
s = {"A", "B"}
bstrs = {}
for i = 1 to length(s) do
bstrs &= alloc_bstr( s[i] )
end for
atom array
array = create_safearray( bstrs, VT_BSTR )
...
destroy_safearray( array )