How to compare BSTR against a string in c/c++?

前端 未结 4 1583
名媛妹妹
名媛妹妹 2021-01-11 16:32
wprintf(L\"Selecting Audio Input Device: %s\\n\", 
                            varName.bstrVal);

if(0 == strcmp(varName.bstrVal, \"IP Camera [JPEG/MJPEG]\"))...
         


        
4条回答
  •  耶瑟儿~
    2021-01-11 17:05

    I always construct _bstr_t wrappers around BSTRs. It makes things quite a bit easier and more idiomatic:

    if(std::string("IP Camera [JPEG/MJPEG]") ==
                       static_cast( _bstr_t(varName.bstrVal) )
    {
    }
    

提交回复
热议问题