> Im gonna send a stream of any type to an external unit.
> Advise pse on how to figure out what the incoming stream format is going to
> be, so I can take the relevant action on it in the external unit.
> It could be a memorystream, filestream, string, Stringlist and so on.
You don't need to know... The caller creates the stream and passes it to you
and you use the same commands regardless..
Size
Position
Read
Write
Seek (although some of them don't allow seek you can test this in your code)
Source.Seek(0,ofFromCurrent); will throw an exception for streams that don't
support seeking.
See the help for TStream for all commands generically support by ALL TStream
descendants.
EG Copy stream to disk regardless of streamtype...
procedure CopyToFile(Source :TStream; const FileName :String);
begin
with TFileStream.Create(FileName,fmCreate or fmShareExclusive) do try
CopyFrom(Source,Source.Size);
finally
Free;
end;
end;
var
A :TStringstream;
B :TFileStream;
begin
A := TStringStream.Create('Spam');
B := TFileStream.Create('C:\Windows\win.ini',fmOpenRead or fmShareDenyWrite);
copyToFile(A,'A.dat');
copyToFile(B,'B.dat');
B.Free;
A.Free;
end.
--
Aaron@home
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz