我想把下面的Unicode 转换成Multi 弄了好久也不成功 请哪位朋友指教一下谢谢了
Unicode
WCHAR *ImgInfoBuf, TempString[100];
DWORD ImgInfoBufSize;
WIMGetImageInformation(hImg, (LPVOID *)&ImgInfoBuf, &ImgInfoBufSize);
wsprintf(TempString, TEXT("<IMAGE INDEX=\"%d\">"), imgNum);
WCHAR *StringPointer = wcsstr(ImgInfoBuf, TempString);
WCHAR *SecondString = wcsstr(++StringPointer, TEXT("<"));
SecondString[-1] = 0; //end the first string Multi
//Get the info and divide it into two strings
WCHAR *ImgInfoBuf, TempString[100];
DWORD ImgInfoBufSize;
WIMGetImageInformation(hImg, (LPVOID *)&ImgInfoBuf, &ImgInfoBufSize);
wsprintf(TempString, TEXT("<IMAGE INDEX=\"%d\">"), imgNum);
const unsigned char *StringPointer = _mbsstr((const unsigned char *)ImgInfoBuf, (const unsigned char *)TempString);
const unsigned char *SecondString = _mbsstr(++StringPointer, (const unsigned char *)("<"));
SecondString[-1] = 0; //end the first string 报错
Unicode
WCHAR *ImgInfoBuf, TempString[100];
DWORD ImgInfoBufSize;
WIMGetImageInformation(hImg, (LPVOID *)&ImgInfoBuf, &ImgInfoBufSize);
wsprintf(TempString, TEXT("<IMAGE INDEX=\"%d\">"), imgNum);
WCHAR *StringPointer = wcsstr(ImgInfoBuf, TempString);
WCHAR *SecondString = wcsstr(++StringPointer, TEXT("<"));
SecondString[-1] = 0; //end the first string Multi
//Get the info and divide it into two strings
WCHAR *ImgInfoBuf, TempString[100];
DWORD ImgInfoBufSize;
WIMGetImageInformation(hImg, (LPVOID *)&ImgInfoBuf, &ImgInfoBufSize);
wsprintf(TempString, TEXT("<IMAGE INDEX=\"%d\">"), imgNum);
const unsigned char *StringPointer = _mbsstr((const unsigned char *)ImgInfoBuf, (const unsigned char *)TempString);
const unsigned char *SecondString = _mbsstr(++StringPointer, (const unsigned char *)("<"));
SecondString[-1] = 0; //end the first string 报错
//**************************************
// unicode字符串转ansi字符串
// 返回大于0成功,小于0失败
//**************************************
int
ustr_astr( WCHAR *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 ( result - 1 );
}
catch( ... )
{
ShowError();
}
return result;
}
TEXT都换成 L 问题就解决了
谢谢大家了