CComBSTR::operator !

检查 BSTR 字符串是否为NULL。

bool operator !( ) const throw( );

返回值

如果 m_str 成员是 NULL,返回 true ;否则,false

备注

此运算符只检查NULL值,不+一个空字符串。

示例

// STDMETHOD(BSTRToUpper)(/*[in, out]*/ BSTR bstrConv);
STDMETHODIMP InplaceBSTRToUpper(BSTR bstrConv)
{
   // Assign bstrConv to m_str member of CComBSTR
   CComBSTR bstrTemp;
   bstrTemp.Attach(bstrConv); 

   // Make sure BSTR is not NULL string 
   if (!bstrTemp)
        return E_POINTER;

   // Make string uppercase 
   HRESULT hr;
   hr = bstrTemp.ToUpper();
   if (hr != S_OK)
       return hr;

   // Set m_str to NULL, so the BSTR is not freed
   bstrTemp.Detach(); 

   return S_OK; 
}

要求

Header: atlbase.h

请参见

参考

CComBSTR 类