bool RenderFile(const char * inFile)
{
int len;
WCHAR szFilePath[MAX_PATH];
//把传入的文件名转换成宽字符串
len=MultiByteToWideChar(CP_ACP,0,inFile,-1,szFilePath,MAX_PATH); //len为什么一直为1......//这里略掉N多行代码,我的感觉是上面哪句没有转换成功,所以一直不会返回true
if(...)
return true;return false; // 正常是不会执行这一句的,因为}
//--------------bool test(const CString &strSourceFile)
{ //Unicode模式下,把CString 转换成Char
wchar_t *wchar;
CString str=strSourceFile;
wchar=str.GetBuffer();
str.ReleaseBuffer();
size_t convertedChars=0;
size_t sizeInBytes=((str.GetLength()+1)*2);
char *p=(char *)malloc(sizeInBytes);
wcstombs_s(&convertedChars,p,sizeInBytes,wchar,sizeInBytes);
if (!RenderFile(p))//这里总为false
{
MessageBox(__T("出错了"),__T("系统提示"),MB_ICONWARNING);
return false;
}
return true;
}
{
int len;
WCHAR szFilePath[MAX_PATH];
//把传入的文件名转换成宽字符串
len=MultiByteToWideChar(CP_ACP,0,inFile,-1,szFilePath,MAX_PATH); //len为什么一直为1......//这里略掉N多行代码,我的感觉是上面哪句没有转换成功,所以一直不会返回true
if(...)
return true;return false; // 正常是不会执行这一句的,因为}
//--------------bool test(const CString &strSourceFile)
{ //Unicode模式下,把CString 转换成Char
wchar_t *wchar;
CString str=strSourceFile;
wchar=str.GetBuffer();
str.ReleaseBuffer();
size_t convertedChars=0;
size_t sizeInBytes=((str.GetLength()+1)*2);
char *p=(char *)malloc(sizeInBytes);
wcstombs_s(&convertedChars,p,sizeInBytes,wchar,sizeInBytes);
if (!RenderFile(p))//这里总为false
{
MessageBox(__T("出错了"),__T("系统提示"),MB_ICONWARNING);
return false;
}
return true;
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货