TCHARToString

std::string CAlarmWin::TCHARToString( TCHAR* tszBuf )
{
	int nLen = WideCharToMultiByte(CP_ACP, 0,tszBuf, -1, NULL, 0, NULL, NULL);
	char* szRtn = new char[nLen*sizeof(char)];
	WideCharToMultiByte(CP_ACP, 0, tszBuf, -1, szRtn, nLen, NULL, NULL);
	std::string strExp(szRtn);
	CString strTemp = strExp.c_str();
	if (NULL != szRtn)
	{
	  delete []szRtn;
	  szRtn = NULL;
	}
	CStringA strExpressionTemp(strTemp.GetBuffer(0));
	strExp = strExpressionTemp.GetBuffer(0);
	strExpressionTemp.ReleaseBuffer();
	return strExp;	
}

  

原文地址:https://www.cnblogs.com/Werial/p/11448520.html