Win: Fix LoadStringA

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman 2025-01-30 13:44:40 +01:00
parent 9ce2e578bb
commit 892d950f2b

View File

@ -702,12 +702,12 @@ static _Success_(return > 0) int NormalizeString(_In_ NORM_FORM NormForm, _In_ c
template<class _Traits, class _Ax> template<class _Traits, class _Ax>
static _Success_(return != 0) int LoadStringA(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_ std::basic_string<char, _Traits, _Ax> &sBuffer) noexcept static _Success_(return != 0) int LoadStringA(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_ std::basic_string<char, _Traits, _Ax> &sBuffer) noexcept
{ {
// Get read-only pointer to string resource. // Get read-only pointer to string resource. Works with LoadStringW only.
LPCSTR pszStr; LPCWSTR pszStr;
int i = LoadStringA(hInstance, uID, reinterpret_cast<LPSTR>(&pszStr), 0); int i = LoadStringW(hInstance, uID, reinterpret_cast<LPWSTR>(&pszStr), 0);
if (i) { if (i) {
sBuffer.assign(pszStr, i); i = wcsnlen_s(pszStr, i);
return i; return WideCharToMultiByte(CP_ACP, 0, pszStr, i, sBuffer, NULL, NULL);
} else } else
return 0; return 0;
} }