Einzelnen Beitrag anzeigen

Muetze1
(Gast)

n/a Beiträge
 
#5

Re: Record aus stream auslesen

  Alt 24. Apr 2004, 21:52
Moin!

Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TTest=record
    a,b,c: ShortString;
  end;
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    Procedure FormCreate(Sender: TObject);
    Procedure FormDestroy(Sender: TObject);
  private
    { Private-Deklarationen } 
    Test : TTest;
    TestStrm : TMemoryStream;
  public
    { Public-Deklarationen } 
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm} 

procedure TForm1.Button1Click(Sender: TObject);
begin
  Test.a := 'a';
  Test.b := 'b';
  Test.c := 'c';

  TestStrm.Position := 0;
  TestStrm.Write(Test, sizeof(TTest));
end;

procedure TForm1.Button2Click(Sender: TObject);
Var
  Test2: TTest;
begin
  TestStrm.Position := 0;
  TestStrm.Read(Test2, SizeOf(TTest));
end;

Procedure TForm1.FormCreate(Sender: TObject);
begin
  TestStrm := TMemoryStream.Create;
end;

Procedure TForm1.FormDestroy(Sender: TObject);
begin
  TestStrm.Free;
end;

end.
MfG
Muetze1
  Mit Zitat antworten Zitat