<div dir="ltr"><div dir="ltr"><div>Did you mean the wrapped class destructor? It's not the case I want...</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>struct IDemo<br></div><div>{</div><div>    virtual void do_sth(BSTR bstr) = 0;<br></div><div>};</div></blockquote><div><br></div><div>The IDemo is created by other C++ interface, the correct way to pass the bstr to <b>do_sth </b>is call <b>SysAllocString</b>,</div><div>and after the call returned, we need call <b>SysFreeString</b> to free the bstr. Because the IDemo instance will not take over the ownership of the bstr.<br></div><div><br></div><div>So when mapped the BSTR to str, it seems that we don't have any chance to call the <b>SysFreeString </b>to free the str that allocated inside <b>%ConvertToTypeCode.</b></div><div><br></div><div><br><b></b></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 20, 2020 at 5:07 PM Phil Thompson <<a href="mailto:phil@riverbankcomputing.com">phil@riverbankcomputing.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I meant the C++ destructor, not __dtor__.<br>
<br>
Phil<br>
</blockquote></div></div>