0

Is there any way to retrieve information from a CArchive file if we don't know what type of objects are stored in the CArchive file?

I want to know in what format information is stored in a CArchive file.

Please help me out in this.

Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164
  • 2
    The `CArchive` class has an underlying file object, and that file is (generally) in binary format. So, unless you know *something* about it's contents, it's just gobbledegook. – Adrian Mole Sep 01 '21 at 16:40
  • 1
    I would open that file in a binary editor and see if you can recognize any strings in it. If that archive was created with MFC's serializable CObject-derived things, you may see the class names. If you are lucky – Vlad Feinstein Sep 01 '21 at 17:21
  • One Carchive file has given to me. I don't anything what type of information it contains. There is no way to retrieve information from that Carchive file? – user1710979 Sep 01 '21 at 17:23

1 Answers1

5

The file format is documented under TN002: Persistent Object Data Format. While that explains how objects are identified in the data stream for deserialization, the actual logic to dump data into the CArchive and to read it back is at the discretion of the CObject-derived class implementation for classes that use the DECLARE_SERIAL and IMPLEMENT_SERIAL macros.

Without the actual (de-)serialization code there's little you can do with a binary CArchive stream, unless the implementation that produced it uses the standard serialization methods throughout, allowing you to guess the data types stored.

Unlike JSON or XML, though, a CArchive's serialized data isn't self-describing. Even when you know the type of any given piece of data, there's nothing in the file that carries any semantic information.

IInspectable
  • 46,945
  • 8
  • 85
  • 181