treats it as a long value, so it doesn't really know if it is a BSTR or not.
But I do - it is a Wstring.
<long variable> = RemoveAny( s1$, s2$ )
PeekS <long variable>
SysFreeString <long variable>
If it
was a BSTR then the above would cause an access violation because PeekS, defaulting to reading unicode, would attempt to read a BSTR.
However, I now take your point about a memory leak.
If I changed back to 'Export as String', instead of 'Export as Wstring', then this works.
ptr.l = RemoveAny( s1$, s2$ )
MessageRequester( "", PeekS( ptr.l, -1, #PB_Ascii ) )
SysFreeString_( ptr.l )
The BSTR is now being read as Ascii and is then freed.
Alternatively, we could have
ptr.l = RemoveAny( s1$, s2$ )
s3$ = PeekS( ptr.l, -1, #PB_Ascii )
SysFreeString_( ptr.l )
The BSTR is read correctly and then converted to unicode.
Thanks, José.