<div dir="ltr"><div dir="ltr"><div>If you mean write the %MethodCode handwritten code to deal all the methods that contains the BSTR, it's the orignal resolution that I thought before...</div><div><br></div><div>I should now start writing the script to do all the works. LoL<br></div><div><br></div><div> Thanks.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 20, 2020 at 8:59 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">Read the %MethodCode documentation.<br>
<br>
On 20/02/2020 12:49, Weitian Leung wrote:<br>
> Did you mean the wrapped class destructor? It's not the case I want...<br>
> <br>
> struct IDemo<br>
>> {<br>
>>     virtual void do_sth(BSTR bstr) = 0;<br>
>> };<br>
>> <br>
> <br>
> The IDemo is created by other C++ interface, the correct way to pass <br>
> the<br>
> bstr to *do_sth *is call *SysAllocString*,<br>
> and after the call returned, we need call *SysFreeString* to free the <br>
> bstr.<br>
> Because the IDemo instance will not take over the ownership of the <br>
> bstr.<br>
> <br>
> So when mapped the BSTR to str, it seems that we don't have any chance <br>
> to<br>
> call the *SysFreeString *to free the str that allocated inside<br>
> *%ConvertToTypeCode.*<br>
> <br>
> <br>
> <br>
> On Thu, Feb 20, 2020 at 5:07 PM Phil Thompson <br>
> <<a href="mailto:phil@riverbankcomputing.com" target="_blank">phil@riverbankcomputing.com</a>><br>
> wrote:<br>
> <br>
>> I meant the C++ destructor, not __dtor__.<br>
>> <br>
>> Phil<br>
>> <br>
<br>
</blockquote></div></div>