如何比较两个BSTR或CComBSTR? [英] How to compare two BSTRs or CComBSTRs?
本文介绍了如何比较两个BSTR或CComBSTR?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
比较两个CComBSTR的正确方法是什么?我尝试使用
What is the right way to compare two CComBSTRs? I tried to use
bool operator ==(
const CComBSTR& bstrSrc
) const throw( );
但是,即使两个ComBSTR相同,它也总是返回false.它不能正常工作.
However it always return false even two ComBSTRs are the same. It did not work correctly.
我必须先将 CComBSTRs 转换为ANSI字符串,然后再使用strcmp吗?
Do I have to convert CComBSTRs to ANSI string first and then use strcmp?
谢谢!
-bc
推荐答案
You should probably use VarBstrCmp
.
这实际上是CComBSTR::operator==
的工作,因此,如果没有进一步的上下文,您的代码可能不正确.
this is actually what CComBSTR::operator==
does, so without further context, your code may be incorrect.
这篇关于如何比较两个BSTR或CComBSTR?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文