二进制的DFM文件如何用代码将其转换成纯文本文件?(20分)

  • 主题发起人 主题发起人 kingbenz
  • 开始时间 开始时间
K

kingbenz

Unregistered / Unconfirmed
GUEST, unregistred user!
如下面的二进制字符如何转换成最下面的纯文本?
 
function ComponentToString(Component: TComponent): string;
var
BinStream:TMemoryStream;
StrStream: TStringStream;
s: string;
begin
BinStream := TMemoryStream.Create;
try
StrStream := TStringStream.Create(s);
try
BinStream.WriteComponent(Component);
BinStream.Seek(0, soFromBeginning);
ObjectBinaryToText(BinStream, StrStream);
StrStream.Seek(0, soFromBeginning);
Result:= StrStream.DataString;
finally
StrStream.Free;
end;
finally
BinStream.Free
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
Memo1.Lines.Text := ComponentToString(Form1);
end;
 
接受答案了.
 
后退
顶部