修复 Path::extractResource 提取失败时仍返回路径的BUG

This commit is contained in:
Haibo 2018-05-27 01:48:26 +08:00
parent 02c740be80
commit 41c9ddcc54
2 changed files with 15 additions and 6 deletions

View File

@ -283,7 +283,7 @@ bool e2d::Image::preload(int resNameId, const String& resType)
if (SUCCEEDED(hr))
{
// 计算大小
imageFileSize = SizeofResource(HINST_THISCOMPONENT, imageResHandle);
imageFileSize = ::SizeofResource(HINST_THISCOMPONENT, imageResHandle);
hr = imageFileSize ? S_OK : E_FAIL;
}

View File

@ -136,11 +136,20 @@ e2d::String e2d::Path::extractResource(int resNameId, const String & resType, co
HGLOBAL hMem = ::LoadResource(NULL, hRes);
DWORD dwSize = ::SizeofResource(NULL, hRes);
if (hRes && hMem && dwSize)
{
// 写入文件
DWORD dwWrite = 0;
::WriteFile(hFile, hMem, dwSize, &dwWrite, NULL);
::CloseHandle(hFile);
return destFilePath;
}
else
{
::CloseHandle(hFile);
::DeleteFile((LPCWSTR)destFilePath);
return String();
}
}
e2d::String e2d::Path::getDataSavePath()