Alterado para PChar para que retorne corretamente a mensagem de erro.
Como era antes:
{ TACBrHTTPReqResp }
function TACBrHTTPReqResp.GetWinInetError(ErrorCode:Cardinal): AnsiString;
const
winetdll = 'wininet.dll';
var
Len: Integer;
Buffer: PAnsiChar;
begin
Len := FormatMessage(
FORMAT_MESSAGE_FROM_HMODULE or FORMAT_MESSAGE_FROM_SYSTEM or
FORMAT_MESSAGE_ALLOCATE_BUFFER or FORMAT_MESSAGE_IGNORE_INSERTS or FORMAT_MESSAGE_ARGUMENT_ARRAY,
Pointer(GetModuleHandle(winetdll)), ErrorCode, 0, @Buffer, SizeOf(Buffer), nil);
try
while (Len > 0) and {$IFDEF UNICODE}{$IFDEF FPC} (Buffer[Len - 1] in [#0..#32, '.'])
{$ELSE} (CharInSet(Buffer[Len - 1], [#0..#32, '.'])) {$ENDIF}
{$ELSE}(Buffer[Len - 1] in [#0..#32, '.']) {$ENDIF} do Dec(Len);
SetString(Result, Buffer, Len);
finally
LocalFree(HLOCAL(Buffer));
end;
end;
Nova function:
{ TACBrHTTPReqResp }
function TACBrHTTPReqResp.GetWinInetError(ErrorCode:Cardinal): AnsiString;
const
winetdll = 'wininet.dll';
var
Len: Integer;
Buffer: PChar;
begin
Len := FormatMessage(
FORMAT_MESSAGE_FROM_HMODULE or FORMAT_MESSAGE_FROM_SYSTEM or
FORMAT_MESSAGE_ALLOCATE_BUFFER or FORMAT_MESSAGE_IGNORE_INSERTS or FORMAT_MESSAGE_ARGUMENT_ARRAY,
Pointer(GetModuleHandle(winetdll)), ErrorCode, 0, @Buffer, SizeOf(Buffer), nil);
try
while (Len > 0) and {$IFDEF UNICODE}{$IFDEF FPC} (Buffer[Len - 1] in [#0..#32, '.'])
{$ELSE} (CharInSet(Buffer[Len - 1], [#0..#32, '.'])) {$ENDIF}
{$ELSE}(Buffer[Len - 1] in [#0..#32, '.']) {$ENDIF} do Dec(Len);
SetString(Result, Buffer, Len);
finally
LocalFree(HLOCAL(Buffer));
end;
end;