xstreams.pas
来自「在深度历险网站上发布的所有delphi程序原码。对初学delphi者很有用。」· PAS 代码 · 共 67 行
PAS
67 行
unit xStreams;
interface
uses Windows, SysUtils, Classes, Forms, TypInfo;
procedure SavePropertyToStream(Stream: TStream; Instance: TPersistent; PropName: string);
procedure LoadPropertyFromStream(Stream: TStream; Instance: TPersistent);
procedure ReadFormAsText(AExeName, AClassName: string; Strings: TStrings);
procedure WriteFormAsBinary(AExeName, AClassName: string; Strings: TStrings);
function VisualizeForm(Strings: TStrings): TForm;
procedure TextizeForm(AForm: TForm; Strings: TStrings);
implementation
type
TMyWriter = class(TWriter)
public
procedure WriteProperty(Instance: TPersistent; PropInfo: Pointer);
end;
TMyReader = class(TReader)
public
procedure ReadProperty(Instance: TPersistent);
end;
{ TMyWriter }
procedure TMyWriter.WriteProperty(Instance: TPersistent; PropInfo: Pointer);
begin
inherited WriteProperty(Instance, PropInfo);
end;
{ TMyReader }
procedure TMyReader.ReadProperty(Instance: TPersistent);
begin
inherited ReadProperty(Instance);
end;
procedure SavePropertyToStream(Stream: TStream; Instance: TPersistent; PropName: string);
begin
with TMyWriter.Create(Stream, 4096) do
try
WriteListBegin;
WriteProperty(Instance, GetPropInfo(Instance.ClassInfo, PropName));
WriteListEnd;
finally
Free;
end;
end;
procedure LoadPropertyFromStream(Stream: TStream; Instance: TPersistent);
begin
with TMyReader.Create(Stream, 4096) do
try
ReadListBegin;
while not EndOfList do ReadProperty(Instance);
ReadListEnd;
finally
Free;
end;
end;
// 盢 form
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?