File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -975,16 +975,21 @@ CString CCommon::GetTextResource(UINT id, int code_type)
975975 HRSRC hRes = FindResource (NULL , MAKEINTRESOURCE (id), _T (" TEXT" ));
976976 if (hRes != NULL )
977977 {
978+ DWORD resSize = SizeofResource (NULL , hRes); // 获取资源的大小
978979 HGLOBAL hglobal = LoadResource (NULL , hRes);
979980 if (hglobal != NULL )
980981 {
982+ LPVOID pResourceData = LockResource (hglobal); // 获取资源数据的指针
981983 if (code_type == 2 )
982984 {
983- res_str = (const wchar_t *)hglobal;
985+ // 资源是宽字符字符串
986+ res_str = CString ((const wchar_t *)pResourceData, resSize / sizeof (wchar_t ));
984987 }
985988 else
986989 {
987- res_str = CCommon::StrToUnicode ((const char *)hglobal, (code_type != 0 )).c_str ();
990+ // 资源是窄字符字符串
991+ std::string strData ((const char *)pResourceData, resSize);
992+ res_str = CCommon::StrToUnicode (strData.c_str (), (code_type != 0 )).c_str ();
988993 }
989994 }
990995 }
You can’t perform that action at this time.
0 commit comments