如下,提示“error C2664: 'ExtTextOutW' : cannot convert parameter 6 from 'const char *' to 'LPCWSTR'”ExtTextOut(hDC,0,0,ETO_CLIPPED,&rect,ostr.str().c_str(),ostr.str().length(),NULL);其中,ostr是ostringstream,如何转换?
调试欢乐多
// ansi字符串转unicode字符串
// 返回大于0成功,小于0失败
//**************************************
int
astr_ustr( char *ansistr, WCHAR *unicodestr )
{
int result = 0;
try
{
//size_t len = strlen( ansistr );
int needlen = MultiByteToWideChar( CP_ACP, 0, ansistr, -1, NULL, 0 );
if( needlen < 0 )
{
return needlen;
} result = MultiByteToWideChar( CP_ACP, 0, ansistr, -1, unicodestr, needlen );
if( result < 0 )
{
return result;
}
return result;
}
catch( ... )
{
ShowError();
}
return result;
}
-->
CString strText(ostr.str().c_str());
ExtTextOut(hDC,0,0,ETO_CLIPPED,&rect,strText, strText.GetLength(), NULL);