<div dir="ltr">Thank you for commenting.<br><div class="gmail_extra"><br><div class="gmail_quote">2015-03-02 16:17 GMT+08:00 Nikolay Sivov <span dir="ltr"><<a href="mailto:bunglehead@gmail.com" target="_blank">bunglehead@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 02.03.2015 11:12, Shuai Meng wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ HRESULT hres;<br>
+ BSTR bstr;<br>
+ WCHAR ret;<br>
+<br>
+ TRACE("(%s)\n", debugstr_variant(arg));<br>
+<br>
+ switch(V_VT(arg)) {<br>
+ case VT_NULL:<br>
+ return MAKE_VBSERROR(VBSE_ILLEGAL_<u></u>NULL_USE);<br>
+ case VT_EMPTY:<br>
+ return MAKE_VBSERROR(VBSE_ILLEGAL_<u></u>FUNC_CALL);<br>
+ case VT_BSTR:<br>
+ bstr = V_BSTR(arg);<br>
+ default:<br>
+ hres = to_string(arg, &bstr);<br>
+ if(FAILED(hres))<br>
+ return hres;<br>
+ }<br>
+<br>
+ ret = bstr[0];<br>
+ if(ret == 0)<br>
+ return MAKE_VBSERROR(VBSE_ILLEGAL_<u></u>FUNC_CALL);<br>
+ return return_short(res, ret);<br>
</blockquote>
<br>
Looks like you need to handle VT_NULL explicitly and after that only distinguish between VT_BSTR or the rest. </blockquote><div>Yes,you are right. </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Also you're leaking memory and missing a 'break'.<br>
</blockquote></div><br></div></div>