[Post] detailed explanation of the PDB File Format

Source: Internet
Author: User
As a reference for the next version of the "Mobile Phone ebook expert!

PDB file structure

PDB is short for Palm database. It is a binary file in a simple format. You only need to figure out the format of the PDB file, and you can read and write it on the PC.

1. Overall structure of the PDB File
The PDB file consists of the following three parts,

Header)
Record entry Index)
Record Data)

The file header contains the database name, attributes, and creation time. The record index is a bit like the book directory. You can find the first few records on the "page" (offset) according to this directory ). The data part is the real data.

2. File Header
The structure of the file header is as follows:

Use ultraedit to open a PDB file for Strength Analysis
PDB Header

Database Name

The blue part in the figure is the database name, which consists of 21 bytes and ends with an empty character 00.

Create Time, modified time, backup time
12 bytes

Type, creator ID
8 bytes

Records count
2 bytes

End of File Header

3. Record Data

Record Index

Index of the first record

The formula for calculating the n record index is as follows:
78 + (n-1) * 8

Record Data

According to the index of 2nd records, the data part of the 2nd records starts at 00 00 80,

After understanding the structure of PDB, you can writeProgramI used Delphi to define a PDB class,

// Class PDB
Type
Tpdb = Class
Private
Fdbname: string;
Fflags: integer;
Fcreatetime: tdatetime;
Fmodifitime: tdatetime;
Ftype1: string;
Fcreatorid: string;
Frecordcount: integer;
Findex: array of integer;
Fattrib: array of integer;
Frecsize: array of integer;
Fdata: array of string;
Procedure setdbname (const value: string );
Procedure setflags (const value: integer );
Procedure setcreatetime (const value: tdatetime );
Procedure setmodifitime (const value: tdatetime );
Procedure settype1 (const value: string );
Procedure setcreatorid (const value: string );
Procedure setrecordcount (const value: integer );

Public
Constructor create (pdbfile: string );
Property dbname: String read fdbname write setdbname;
Property flags: integer read fflags write setflags;
Property createtime: tdatetime read fcreatetime write setcreatetime;
Property modifitime: tdatetime read fmodifitime write setmodifitime;
Property type1: String read ftype1 write settype1;
Property creatorid: String read fcreatorid write setcreatorid;
Property recordcount: integer read frecordcount write setrecordcount;
Function getrecords (I: integer): string;
End;

Next, you can use a file stream tfilestream to read and write data.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.