I'm trying to load a resource from a TMemoryStream using the function:
function ExtrairRecursosMemoria(NomeRecurso: String): TStream;
var
Recurso: TLResource;
StreamRecurso: TLazarusResourceStream;
MemStreamRecurso: TMemoryStream;
begin
Result := nil;
StreamRecurso := nil;
Recurso := LazarusResources.Find(NomeRecurso);
if Recurso = nil then
begin
raise Exception.Create('Recurso com nome "' + NomeRecurso + '" não foi encontrado.');
end;
begin
try
try
StreamRecurso := TLazarusResourceStream.Create(NomeRecurso, nil);
MemStreamRecurso := TMemoryStream.Create;
MemStreamRecurso.CopyFrom(StreamRecurso, StreamRecurso.Size);
MemStreamRecurso.Position := 0;
Result := MemStreamRecurso;
except
on E: Exception do
begin
ShowMessage('Error')
end;
end;
finally
StreamRecurso.Free;
end;
end;
end;
I use the function as follows:
var
ReportStream: TStream;
begin
ReportStream := ExtrairRecursosMemoria('history');
try
try
ReportStream.Position := 0;
frlrRelatorioHistorico.LoadFromStream(ReportStream);
frlrRelatorioHistorico.ShowReport;
except
on E: Exception do
begin
ShowMessage('Error')
end;
end;
finally
MemStreamRecurso.Free;
end;
end;
When I try to extract I get an error "invalid binary report: invalid report version (60)". But if I save the physical file and load it from disk it works normally.