Solution 1. You can use JVCL TJvAppXMLFileStorage. But JVCL is huge!! You have to consider twice if you want or not, to drag such a huge dependency after you, your whole life.
Solution 2. Save your object to a binary file (my preferred solution). Believe me, it is not that hard.
Use the ccStreamMem.pas, or even better the ccStreamBuff.pas (buffered writing) in my LightSaber Core library.
You have some code examples on how to do it, in Delphi in all its glory book.
PS: LightSaber is a lightweight alternative to JVCL.
Here is an example of how to save a record to a binary file. The operation is identical for TObject!
// Supposing you have a record (could be also an object) called RAnimationParams that you want to save to disk:
INTERFACE
USES
System.SysUtils, Vcl.Graphics, ccStreamBuff;
TYPE
TFrameDelayType = (fdAuto, fdUser);
RAnimationParams = record
Color : TColor;
DelayType : TFrameDelayType;
procedure WriteToStream (IOStream: TCubicBuffStream);
procedure ReadFromStream(IOStream: TCubicBuffStream);
end;
IMPLEMENTATION
procedure RAnimationParams.WriteToStream(IOStream: TCubicBuffStream);
begin
IOStream.WriteByte (Ord(DelayType));
IOStream.WriteInteger (Color);
IOStream.WritePadding (32);
end;
procedure RAnimationParams.ReadFromStream(IOStream: TCubicBuffStream);
begin
DelayType := TFrameDelayType(IOStream.ReadByte);
Color := IOStream.ReadInteger;
IOStream.ReadPadding (32);
end;
The padding at the end allows you to change your record/object structure later, without changing the format of your binary file.
To actually save the RAnimationParams to disk you just do:
MyBinFile:= TCubicBuffStream.CreateRead('C:\Test.bin');
AnimationParams.WriteToStream(MyBinFile);
MyBinFile.Free;
Same code when you want to load the RAnimationParams back from Test.bin, but you use CreateWrite instead of CreateRead.
The TCubicBuffStream class has even dedicated functions such as ReadHeader/CreateWrite that allow you to easily add "file magic numbers" and "file version numbers" to your binary files.
See? Not so difficult. And it will work for any object, not only for TComponent.