Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 // Windows/Error.h
3 #include "StdAfx.h"
5 #include "Windows/Error.h"
6 #ifndef _UNICODE
7 #include "Common/StringConvert.h"
8 #endif
10 #ifndef _UNICODE
11 extern bool g_IsNT;
12 #endif
14 namespace NWindows {
15 namespace NError {
17 bool MyFormatMessage(DWORD messageID, CSysString &message)
18 {
19 LPVOID msgBuf;
20 if(::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
21 FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
22 NULL,messageID, 0, (LPTSTR) &msgBuf,0, NULL) == 0)
23 return false;
24 message = (LPCTSTR)msgBuf;
25 ::LocalFree(msgBuf);
26 return true;
27 }
29 #ifndef _UNICODE
30 bool MyFormatMessage(DWORD messageID, UString &message)
31 {
32 if (g_IsNT)
33 {
34 LPVOID msgBuf;
35 if(::FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
36 FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
37 NULL, messageID, 0, (LPWSTR) &msgBuf, 0, NULL) == 0)
38 return false;
39 message = (LPCWSTR)msgBuf;
40 ::LocalFree(msgBuf);
41 return true;
42 }
43 CSysString messageSys;
44 bool result = MyFormatMessage(messageID, messageSys);
45 message = GetUnicodeString(messageSys);
46 return result;
47 }
48 #endif
50 }}