把Delphi6格式的dfm文件内容转换为Delphi5格式
uses
Class, RTLConsts, TypInfo;
function ConvertForm(AFormString: string): string;
var
lSrc, lDest: TStringStream;
lBin: TMemoryStream;
begin
lSrc := TStringStream.Create(AFormString);
lDest := TStringStream.Create('');
lBin := TMemoryStream.Create;
try
ObjectTextToBinary(lSrc, lBin);
lBin.Seek(0, soFromBeginning);
ObjectBinaryToTextEx(lBin, lDest);
Result := lDest.DataString;
finally
lSrc.Free;
lDest.Free;
lBin.Free;
end;
end;
其中ObjectBinaryToTextEx是照抄了class.pas中的ObjectBinaryToText过程,改了一点点内容:
case Reader.NextValue of
vaWString, vaUTF8String:
begin
S := Reader.ReadWideString;
ConvertString;
end;
vaString, vaLString:
begin
S := Reader.ReadString;
ConvertString;
end;
end;