Fix occassionally failing FormatMessage call

Call FormatMessage with the IGNORE_INSERTS flag. Without the flag,
the FormatMessage() call will fail when the error message contains
inserts (such as %1), as we are not providing any arguments.

Various Windows system error messages contain inserts; e.g. error 193.

See also: https://devblogs.microsoft.com/oldnewthing/20071128-00/?p=24353
This commit is contained in:
Lauri Nurmi
2019-05-10 17:15:53 +03:00
committed by Lauri Nurmi
parent 18e4cf9b80
commit d2eec4bd90

View File

@@ -1066,7 +1066,8 @@ static const wxChar* GetSysErrorMsg(wxChar* szBuf, size_t sizeBuf, unsigned long
LPVOID lpMsgBuf;
if ( ::FormatMessage
(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
nErrCode,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),