// 如果向对话框添加最小化按钮,则需要下面的代码
// 来绘制该图标。对于使用文档/视图模型的 MFC 应用程序,
// 这将由框架自动完成。
// UNICODE 转换 ANSI 程序
int ustr_astr( CString unicodestr, char *ansistr )
{
int result = 0;
try
{
int needlen = WideCharToMultiByte( CP_ACP, 0, unicodestr, -1, NULL, 0, NULL, NULL );
if( needlen < 0 )
{
return needlen;
}
result = WideCharToMultiByte( CP_ACP, 0, unicodestr, -1, ansistr, needlen + 1, NULL, NULL );
if( result < 0 )
{
return result;
}
return strlen( ansistr );
}
catch( ... )
{
}
return result;
}
//--------------------------------------------------------------------------------------------------------
// ANSI 转换 UNICODE 程序
int astr_ustr(char *ansistr ,WCHAR *unicodestr)
{
int result = 0;
try
{
int needlen = MultiByteToWideChar( CP_ACP, 0, ansistr, -1, NULL, 0);
if( needlen < 0 )
{
return needlen;
}
result = MultiByteToWideChar( CP_ACP, 0, ansistr, -1, unicodestr, needlen + 1);
if( result < 0 )
{
return result;
}
return strlen(ansistr);
}
catch( ... )
{
}
return result;
}