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)
{
...
}
精彩评论