VC++中 Image img(wPicName,TRUE);时出现
unhandled exception in ***.exe (NTDLL.DLL):0xC0000005: Access Violation请教怎么回事?
unhandled exception in ***.exe (NTDLL.DLL):0xC0000005: Access Violation请教怎么回事?
Graphics mGraphics(pDc->GetSafeHdc());
WCHAR wPicName[_MAX_FNAME];
int l = 0;
l = MultiByteToWideChar(CP_ACP, 0, (LPCTSTR)g_LocalParam.chPicFileName, -1, NULL, 0);
MultiByteToWideChar(CP_ACP, 0, (LPCTSTR)g_LocalParam.chPicFileName, -1, wPicName, l);
Image img(wPicName, TRUE);
Image img(wPicName,)
//mGraphics.DrawImage(&img, 6, 8, img.GetWidth() / 3 * 2, img.GetHeight() / 3 * 2);
mGraphics.DrawImage(&img, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN) - 35);
应该是没错的
g_LocalParam.chPicFileName的路径是正确的
wPicName的值是一些Unicode字符,都是些数字,怎么知道它是正确的呢
或者你用AfxMessageBox看一下
str.Format("%s",g_LocalParam.chPicFileName);
AfxMessageBox(str);
AfxMessageBox(str)显示"D:\图片\20100424082751117.jpg"CString str;
str.Format("%s",wPicName);
AfxMessageBox(str);
AfxMessageBox(str)显示"D"