CString 轉換 string類型,该怎么处理

CString 轉換 string類型
CString cstr="abc";
string str ;
str = cstr.GetBuffer(0);

請問我這段代碼錯了嗎?爲什麽會報錯這樣的呢?
error C2440: 'initializing' : cannot convert from 'const char [4]' to 'ATL::CStringT<BaseType,StringTraits>' D:\Project\C++\11\Text\Test\Test\Xml.cpp 89
error C2679: binary '=' : no operator found which takes a right-hand operand of type 'wchar_t *' (or there is no acceptable conversion) D:\Project\C++\11\Text\Test\Test\Xml.cpp 91


------解决方案--------------------
这种情况和使用字符串环境有关 假设是unicode编码环境下 会出现这种错误(没有测试在多字符集合下是怎么样的,应该不会报错)。
在unicode下可以这样用:

CString cstr=_T("abc"); //_T()是一种中间类型
std::string str ;
str = (char*)cstr.GetBuffer(0); //将wchar_t*强制为char*即可使用,不过str是"a"
OutputDebugStringA(str.c_str());
------解决方案--------------------
CString cstr=_T("abc");
string str=(CStringA)cstr;

或者:

string str=(CT2A)cstr;
需要加头文件:#include "atlconv.h"

------解决方案--------------------
string不能处理Unicode字符
解决方法
要么将工程字符集改成未设置
要么用WideCharToMultiByte把你的字符串转成多字节的