A bstr is a unicode zero terminated string with a long in front that contains it's length.
The pointer to a bstr however points to the actual string, so the length is
stored at the *pointer-4 memory location.
The important thing is though that it is allocated with SysAllocString_() and
freed with SysFreeString_(). This ensures that when you pass a bstr to a
function, the function is able to free it. So don't just create a memorybank
and put the string in it, that would be wrong.
So the function posted by tonnelier is the right way to go.
A tip though:
> size.l=MultiByteToWideChar_(#CP_ACP,0,ansi,-1,0,0)
This returnes the needed space in bytes for the new string (not including the
termination 0, which are 2 of them for a unicode string)
So if you do "Dim unicode.w(size)", you actually get double the size
than you actually need, because each word is 2 bytes, but "size.l" contains
the full unicode string length in bytes allready.
So "Dim unicode.b(size+2)" is actually enough to store the new string.
Of course the function works well as it is, because a little more memory
never hurts
Just some info..
Timo