字符串 -> 流:
procedure StreamWriteString(var Stream: TStream; Value: string);
var
Writer: TWriter;
begin
Writer:= TWriter.Create(Stream, 256);
Writer.WriteString(Value);
Writer.Free;
end;
流 -> 字符串:
function StreamReadString(var Stream: TStream): string;
var
Reader: TReader;
begin
Reader:= TReader.Create(Stream, 256);
Result:= Reader.ReadString;
Reader.Free;
end;
结构体 -> 流:
procedure StreamWriteStruct(var Stream: TStream; Struct: _InterPlay);
begin
with Struch do
begin
StreamWriteString(Stream, csFileName);
Stream.Write(iPlayingNo, SizeOf(Integer));
Stream.Write(dwPosition, SizeOf(DWord));
Stream.Write(bInter, SizeOf(Bool));
end;
end;
流 -> 结构体
procedure StreamReadStruct(var Stream: TStream; var Struct: _InterPlay);
begin
with Struct do
begin
csFileName:= StreamReadString(Stream);
Stream.Read(iPlayingNo, SizeOf(Integer));
Stream.Read(dwPosition, SizeOf(DWord));
Stream.Read(bInter, SizeOf(Bool));
end;
end;