开发者

Check if a BSTR is empty

开发者 https://www.devze.com 2023-04-05 04:03 出处:网络
I have a variant that contains a BSTR, but sometimes the BSTR is \"\" (empty), so how开发者_运维技巧 to avoid this? I have tried something like:

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

精彩评论

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