win32API中的LPWSTR(strTemp)和字符"测试"对比怎么不能相等

来源:百度知道 编辑:UC知道 时间:2024/05/05 16:57:46
SendMessage(hwndButton,WM_GETTEXT,255,(LPARAM)strTemp); //我取得一个控件的text内容为“测试”

MessageBox(NULL,LPWSTR(strTemp),TEXT("标题"),MB_OK);//message弹出来也是等于"测试"

if(LPWSTR(strTemp)=="测试")//但是这里取不会相等呢?
{

不能这么比较
可以这样
CString str(strTemp);
if(str=="测试")
{
//TODO you want
}

也可以
CString str(strTemp);
if(str.Compare("测试")==0
{
//TODO you want
}

或者使用strcmp来叫 不过这个好像就不如用MFC