unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls, StdCtrls;
type
TForm1 =
class(TForm)
ListView1: TListView;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private-Deklarationen }
procedure SaveComponentToStream(Stream : TStream; Component : TComponent);
procedure LoadComponentFromStream(Stream : TStream; Component : TComponent);
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
FileStream : TFileStream;
begin
FileStream:=TFileStream.Create(InCludeTrailingBackSlash(ExtractFilePath(Application.Exename))+'
Test.stm',fmCreate);
Try
SaveComponentToStream(FileStream,ListView1);
Finally
FileStream.Free;
end;
end;
procedure TForm1.SaveComponentToStream(Stream: TStream;
Component: TComponent);
begin
Stream.WriteComponent(Component);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
FileStream : TFileStream;
begin
FileStream:=TFileStream.Create(InCludeTrailingBackSlash(ExtractFilePath(Application.Exename))+'
Test.stm',fmOpenRead);
Try
LoadComponentFromStream(FileStream,ListView1);
Finally
FileStream.Free;
end;
end;
procedure TForm1.LoadComponentFromStream(Stream: TStream;
Component: TComponent);
begin
Stream.ReadComponent(Component);
end;
end.