开发者

Check if a BSTR is empty

I have a variant that contains a BSTR, but sometimes the BSTR is "" (empty), so how开发者_运维技巧 to avoid this? I have tried something like:

variant.bstrVal != NULL

But it didn't work.


Use SysStringLen:

if (SysStringLen(variant.bstrVal) == 0)
{ ... }


You can test the vt member of VARIANT for VT_NULL or VT_EMPTY

if (variant.vt != VT_NULL)
{
   ...
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜