From 41c9ddcc54e928a87f3a78e43c13d8bd5d5e7b57 Mon Sep 17 00:00:00 2001 From: Haibo Date: Sun, 27 May 2018 01:48:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20Path::extractResource=20?= =?UTF-8?q?=E6=8F=90=E5=8F=96=E5=A4=B1=E8=B4=A5=E6=97=B6=E4=BB=8D=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E8=B7=AF=E5=BE=84=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/Common/Image.cpp | 2 +- core/Tool/Path.cpp | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/core/Common/Image.cpp b/core/Common/Image.cpp index 6a5b60e4..81d335fb 100644 --- a/core/Common/Image.cpp +++ b/core/Common/Image.cpp @@ -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; } diff --git a/core/Tool/Path.cpp b/core/Tool/Path.cpp index b36bdc70..e6c2a706 100644 --- a/core/Tool/Path.cpp +++ b/core/Tool/Path.cpp @@ -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); - // 写入文件 - DWORD dwWrite = 0; - ::WriteFile(hFile, hMem, dwSize, &dwWrite, NULL); - ::CloseHandle(hFile); - return destFilePath; + 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()