| 
2017/4/17 (月) 07:51:25  Mr.XRAY  |   
▼ Konnoyaさん 
 
> 保存されたファイルのバイナリに変化は無かったと記憶してます。 
 
ですね. 
テキスト形式で保存するとなると,RTTI から取得してとか, 
↓ な方法とか... どちらも実際やってみないとどこまで可能かは不明ですが... 
 
[ Delphi: REST.JSON を利用したオブジェクトの直列化] 
http://d.hatena.ne.jp/igapyon/20151203 
[ユーザー オブジェクトのシリアル化] 
http://docwiki.embarcadero.com/RADStudio/Seattle/ja/%E3%83%A6%E3%83%BC%E3%82%B6%E3%83%BC_%E3%82%AA%E3%83%96%E3%82%B8%E3%82%A7%E3%82%AF%E3%83%88%E3%81%AE%E3%82%B7%E3%83%AA%E3%82%A2%E3%83%AB%E5%8C%96 
 
 
type 
  TMyApp = class(TObject) 
  private 
    FName: string; 
    FAge: Integer; 
    FPhoto: TBytes; 
  published 
    property Name: string read FName write FName; 
    property Age: Integer read FAge write FAge; 
    property Photo: TBytes read FPhoto write FPhoto; 
  end; 
 
  TForm1 = class(TForm) 
    Button1: TButton; 
    Edit1: TEdit; 
    Edit2: TEdit; 
    Image1: TImage; 
    Memo1: TMemo; 
    procedure Button1Click(Sender: TObject); 
    procedure FormCreate(Sender: TObject); 
  private 
    { Private 宣言 } 
  public 
    { Public 宣言 } 
  end; 
 
var 
  Form1: TForm1; 
 
implementation 
 
uses 
  REST.JSON; 
 
{$R *.dfm} 
 
//============================================================================= 
//  フォーム生成時の処理 
//============================================================================= 
procedure TForm1.FormCreate(Sender: TObject); 
begin 
  Caption := 'JSON を利用したシリアライズ'; 
  Edit1.Text := '私は誰'; 
  Edit2.Text := '100'; 
end; 
 
//============================================================================= 
//  Delphi: REST.JSON を利用したオブジェクトの直列化 
// 
//  [いがぴょんの日記@はてな]より 
//  http://d.hatena.ne.jp/igapyon/20151203 
// 
//  usesにREST.JSONが必要 
//  動作確認 Window 7 U64(SP1) + DelphiXE5(UP2) Pro VCL-32 
//============================================================================= 
procedure TForm1.Button1Click(Sender: TObject); 
var 
  LMyApp  : TMyApp; 
  LStream : TMemoryStream; 
begin 
  LMyApp  := TMyApp.Create; 
  LStream := TMemoryStream.Create; 
 
  try 
    LMyApp.name := Edit1.Text; 
    LMyApp.Age  := StrToInt(Edit2.Text); 
    Image1.Picture.Bitmap.SaveToStream(LStream); 
 
    SetLength(LMyApp.FPhoto, LStream.Size); 
    LStream.Position := 0; 
    LStream.Read(LMyApp.Photo[0], LStream.Size); 
 
    Memo1.Lines.Text := TJson.ObjectToJsonString(LMyApp); 
  finally 
    FreeAndNil(LMyApp); 
    FreeAndNil(LStream); 
  end; 
end; 
 
    |   
 |