请问一个BSTR转换成CString的有关问题,小弟我都哭了 .
请教一个BSTR转换成CString的问题,我都哭了 ....
原定义如下:
BSTR nodeName;
iNode-> get_baseName( &nodeName );
CString type;
type = (CString) nodeName;
strcmp(keystr[i][0], type);
错误提示: error C2664: 'strcmp ' : cannot convert parameter 1 from 'class CString ' to 'const char * '
我尝试了format方法如下:
BSTR nodeName;
iNode-> get_baseName( &nodeName );
CComBSTR cName
cName.AppendBSTR( nodeName );
CString strXML( cName );
CString type;
type.Format( L "%s ", strXML, strVal );
strcmp(keystr[i][0], type);
结果还是一样的错误, 请高手指点一下阿.不胜感激!!
------解决方案--------------------
keystr[i][0].GetBuffer(0);
但是我认为你写得是对的,除非你是UNICODE工程。那么你可以wcscmp
------解决方案--------------------
BSTR str;
iNode-> get_baseName(&str);
CString temp(str);
原定义如下:
BSTR nodeName;
iNode-> get_baseName( &nodeName );
CString type;
type = (CString) nodeName;
strcmp(keystr[i][0], type);
错误提示: error C2664: 'strcmp ' : cannot convert parameter 1 from 'class CString ' to 'const char * '
我尝试了format方法如下:
BSTR nodeName;
iNode-> get_baseName( &nodeName );
CComBSTR cName
cName.AppendBSTR( nodeName );
CString strXML( cName );
CString type;
type.Format( L "%s ", strXML, strVal );
strcmp(keystr[i][0], type);
结果还是一样的错误, 请高手指点一下阿.不胜感激!!
------解决方案--------------------
keystr[i][0].GetBuffer(0);
但是我认为你写得是对的,除非你是UNICODE工程。那么你可以wcscmp
------解决方案--------------------
BSTR str;
iNode-> get_baseName(&str);
CString temp(str);