64,282
社区成员
发帖
与我相关
我的任务
分享
CA2T szr(s.c_str());
m_Dis.m_Name = (LPCTSTR)szr;
wstring CXX::AnsiToUnicode (const string& strSrc )
{
/*!< 分配目标空间 */
int iAllocSize = MultiByteToWideChar(CP_ACP,0,strSrc.c_str(),-1,NULL,NULL);
WCHAR* pwszBuffer = new WCHAR[ (UINT)iAllocSize ];
if ( NULL == pwszBuffer )
{
return L"";
}
int iCharsRet = MultiByteToWideChar( CP_ACP, 0, strSrc.c_str(),-1,pwszBuffer, iAllocSize );
/*!< 成功 */
wstring wstrRet;
if ( 0 < iCharsRet )
{
(void)wstrRet.assign ( pwszBuffer, static_cast<size_t>( iCharsRet ) );
}
/*!< 释放内存 */
delete[] pwszBuffer;
return wstrRet;
}