1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/other-licenses/7zstub/src/Windows/Error.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,50 @@ 1.4 +// Windows/Error.h 1.5 + 1.6 +#include "StdAfx.h" 1.7 + 1.8 +#include "Windows/Error.h" 1.9 +#ifndef _UNICODE 1.10 +#include "Common/StringConvert.h" 1.11 +#endif 1.12 + 1.13 +#ifndef _UNICODE 1.14 +extern bool g_IsNT; 1.15 +#endif 1.16 + 1.17 +namespace NWindows { 1.18 +namespace NError { 1.19 + 1.20 +bool MyFormatMessage(DWORD messageID, CSysString &message) 1.21 +{ 1.22 + LPVOID msgBuf; 1.23 + if(::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | 1.24 + FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 1.25 + NULL,messageID, 0, (LPTSTR) &msgBuf,0, NULL) == 0) 1.26 + return false; 1.27 + message = (LPCTSTR)msgBuf; 1.28 + ::LocalFree(msgBuf); 1.29 + return true; 1.30 +} 1.31 + 1.32 +#ifndef _UNICODE 1.33 +bool MyFormatMessage(DWORD messageID, UString &message) 1.34 +{ 1.35 + if (g_IsNT) 1.36 + { 1.37 + LPVOID msgBuf; 1.38 + if(::FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | 1.39 + FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 1.40 + NULL, messageID, 0, (LPWSTR) &msgBuf, 0, NULL) == 0) 1.41 + return false; 1.42 + message = (LPCWSTR)msgBuf; 1.43 + ::LocalFree(msgBuf); 1.44 + return true; 1.45 + } 1.46 + CSysString messageSys; 1.47 + bool result = MyFormatMessage(messageID, messageSys); 1.48 + message = GetUnicodeString(messageSys); 1.49 + return result; 1.50 +} 1.51 +#endif 1.52 + 1.53 +}}