From cd923718c329118a76e8bcf9a90b959553fbf555 Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Fri, 28 Jul 2023 08:10:01 +0200 Subject: CommonFuncs: Add GetWin32ErrorString(). --- Source/Core/Common/CommonFuncs.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'Source/Core/Common/CommonFuncs.cpp') diff --git a/Source/Core/Common/CommonFuncs.cpp b/Source/Core/Common/CommonFuncs.cpp index a1e93455a2..0a546428b7 100644 --- a/Source/Core/Common/CommonFuncs.cpp +++ b/Source/Core/Common/CommonFuncs.cpp @@ -52,10 +52,16 @@ std::string LastStrerrorString() // Wrapper function to get GetLastError() string. // This function might change the error code. std::string GetLastErrorString() +{ + return GetWin32ErrorString(GetLastError()); +} + +// Like GetLastErrorString() but if you have already queried the error code. +std::string GetWin32ErrorString(DWORD error_code) { char error_message[BUFFER_SIZE]; - FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, nullptr, GetLastError(), + FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, nullptr, error_code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), error_message, BUFFER_SIZE, nullptr); return std::string(error_message); } -- cgit v1.2.3