michael@0: // Windows/Error.h michael@0: michael@0: #include "StdAfx.h" michael@0: michael@0: #include "Windows/Error.h" michael@0: #ifndef _UNICODE michael@0: #include "Common/StringConvert.h" michael@0: #endif michael@0: michael@0: #ifndef _UNICODE michael@0: extern bool g_IsNT; michael@0: #endif michael@0: michael@0: namespace NWindows { michael@0: namespace NError { michael@0: michael@0: bool MyFormatMessage(DWORD messageID, CSysString &message) michael@0: { michael@0: LPVOID msgBuf; michael@0: if(::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | michael@0: FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, michael@0: NULL,messageID, 0, (LPTSTR) &msgBuf,0, NULL) == 0) michael@0: return false; michael@0: message = (LPCTSTR)msgBuf; michael@0: ::LocalFree(msgBuf); michael@0: return true; michael@0: } michael@0: michael@0: #ifndef _UNICODE michael@0: bool MyFormatMessage(DWORD messageID, UString &message) michael@0: { michael@0: if (g_IsNT) michael@0: { michael@0: LPVOID msgBuf; michael@0: if(::FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | michael@0: FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, michael@0: NULL, messageID, 0, (LPWSTR) &msgBuf, 0, NULL) == 0) michael@0: return false; michael@0: message = (LPCWSTR)msgBuf; michael@0: ::LocalFree(msgBuf); michael@0: return true; michael@0: } michael@0: CSysString messageSys; michael@0: bool result = MyFormatMessage(messageID, messageSys); michael@0: message = GetUnicodeString(messageSys); michael@0: return result; michael@0: } michael@0: #endif michael@0: michael@0: }}