CString和string在unicode与非unicode下的相互转换
string CString2string(CString csStrData)
{
#ifdef _UNICODE
//如果是unicode工程
USES_CONVERSION;
string str(W2A(csStrData));
return str;
#else
//如果是多字节工程
string str(csStrData.GetBuffer());
csStrData.ReleaseBuffer();
return str;
#endif
}
CString toCString(string str)
{
#ifdef _UNICODE //如果是unicode工程
USES_CONVERSION;
CString s(str.c_str());
CString ans(str.c_str());
return ans;
#else
//如果是多字节工程
CString ans;
ans.Format("%s", str.c_str());
return ans;
#endif
}