* use FormatMessageW in SysErrorMessage, resolves issue #29197

git-svn-id: trunk@32835 -
This commit is contained in:
florian 2016-01-03 15:56:31 +00:00
parent 77229a3cdf
commit d4d4689914

View File

@ -944,16 +944,16 @@ function SysErrorMessage(ErrorCode: Integer): String;
const
MaxMsgSize = Format_Message_Max_Width_Mask;
var
MsgBuffer: pChar;
MsgBuffer: PUnicodeChar;
begin
GetMem(MsgBuffer, MaxMsgSize);
FillChar(MsgBuffer^, MaxMsgSize, #0);
FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM,
GetMem(MsgBuffer, MaxMsgSize*2);
FillChar(MsgBuffer^, MaxMsgSize*2, #0);
FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM,
nil,
ErrorCode,
MakeLangId(LANG_NEUTRAL, SUBLANG_DEFAULT),
MsgBuffer, { This function allocs the memory }
MaxMsgSize, { Maximum message size }
MsgBuffer,
MaxMsgSize,
nil);
SysErrorMessage := MsgBuffer;
FreeMem(MsgBuffer, MaxMsgSize);