From 8566655b85f0a4e515d57f6686636db516116f95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Mon, 22 Aug 2022 13:13:10 +0200 Subject: Improve Win32Error, add Min. --- c/win.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'c/win.cpp') diff --git a/c/win.cpp b/c/win.cpp index 548c951..a09b19b 100644 --- a/c/win.cpp +++ b/c/win.cpp @@ -124,8 +124,8 @@ int GetRelativeCursorPos(const HWND hWnd, POINT* const pt) noexcept return 1; } -Win32Error::Win32Error(const DWORD code) noexcept - : code(code) {} +Win32Error::Win32Error(const DWORD code, const HMODULE hModule) noexcept + : code(code), hModule(hModule) {} Win32Error::~Win32Error() { @@ -143,7 +143,7 @@ const char* Win32Error::what() const noexcept |FORMAT_MESSAGE_FROM_SYSTEM |FORMAT_MESSAGE_FROM_HMODULE |FORMAT_MESSAGE_IGNORE_INSERTS, - GetModuleHandle(L"wininet.dll"), + hModule, code, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), (char*)&m_szMsg, @@ -159,7 +159,7 @@ const wchar_t* Win32Error::What() const noexcept |FORMAT_MESSAGE_FROM_SYSTEM |FORMAT_MESSAGE_FROM_HMODULE |FORMAT_MESSAGE_IGNORE_INSERTS, - GetModuleHandle(L"wininet.dll"), + hModule, code, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), (wchar_t*)&m_wszMsg, @@ -170,7 +170,7 @@ const wchar_t* Win32Error::What() const noexcept InternetError::InternetError(DWORD codeSystem) { if (codeSystem != ERROR_INTERNET_EXTENDED_ERROR) - throw Win32Error(codeSystem); + throw Win32Error(codeSystem, GetModuleHandle(L"wininet.dll")); DWORD len, cch; InternetGetLastResponseInfo(&code, nullptr, &len); -- cgit v1.2.3