如何比较两个 BSTR 或 CComBSTR? [英] How to compare two BSTRs or CComBSTRs?

查看:28
本文介绍了如何比较两个 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

推荐答案

您可能应该使用 VarBstrCmp.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆