U
userlxl
Unregistered / Unconfirmed
GUEST, unregistred user!
使用了一个DFM文件转化到TEXT格式的函数,但运行时却报错:
"invalid stream format"
久闻大富翁盛名,特来向各位高手请教,问题出在那里?
我使用的代码如下:
function tform1.dfmFileLoad(const aFile: String): String;
var
aInput : TStream;
aOutput : TStream;
aStr : TStrings;
begin
Result := '';
aInput := TFileStream.Create(aFile, fmOpenRead);
try
aOutput := TMemoryStream.Create;
try
ObjectResourceToText(aInput,aOutput);
aOutput.Position:=0;
aStr:=TStringList.Create;
try
aStr.LoadFromStream(aOutput);
// aStr.LoadFromStream(ainput);
Result:=aStr.Text;
finally
aStr.Free;
end;
finally
aOutput.Free;
end;
finally
aInput.Free;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
memo1.Lines.add(dfmfileload(extractfilepath(application.ExeName )+'unit1.dfm'));
end;
"invalid stream format"
久闻大富翁盛名,特来向各位高手请教,问题出在那里?
我使用的代码如下:
function tform1.dfmFileLoad(const aFile: String): String;
var
aInput : TStream;
aOutput : TStream;
aStr : TStrings;
begin
Result := '';
aInput := TFileStream.Create(aFile, fmOpenRead);
try
aOutput := TMemoryStream.Create;
try
ObjectResourceToText(aInput,aOutput);
aOutput.Position:=0;
aStr:=TStringList.Create;
try
aStr.LoadFromStream(aOutput);
// aStr.LoadFromStream(ainput);
Result:=aStr.Text;
finally
aStr.Free;
end;
finally
aOutput.Free;
end;
finally
aInput.Free;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
memo1.Lines.add(dfmfileload(extractfilepath(application.ExeName )+'unit1.dfm'));
end;