function CompararStreams(AStream1, AStream2: TStream): boolean;
var
Buff1, Buff2: Pointer;
iCount: LongInt;
const
BUFFER_SIZE = 1024*4;
begin
if AStream1.Size <> AStream2.Size then
Result := False
else
begin
Result := True;
GetMem(Buff1, BUFFER_SIZE);
GetMem(Buff2, BUFFER_SIZE);
try
repeat
iCount := AStream1.Read(Buff1^, BUFFER_SIZE);
AStream2.Read(Buff2^, BUFFER_SIZE);
if not CompareMem(Buff1, Buff2, iCount) then
begin
Result := False;
break;
end;
until iCount < BUFFER_SIZE;
finally
FreeMem(Buff1);
FreeMem(Buff2);
end;
end;
end;