------------------------------------------------------
1. EDB database structure
------------------------------------------------------
The basic unit of an EDB database is volume, that is, a volume, which usually exists in a disk file, such as Pim. Vol.
The volume contains several databases, which can be accessed by the database name or OID (object number). For example, Pim. Vol contains a database named "appointments Database", whose oid is 1077960704.
Each database contains many records. You can access each record by using the oId or sort number in the database.
Each record contains many attributes. Record attribute = record data. The record attributes are stored by the cepropval structure. Each record stores an array of the cepropval type. The array size is the number of attributes.
The attributes of each record are identified by cepropval: propid. Propid is a DWORD data, which defines the property name ID. A low word represents the type of the property data recorded in the database, such as lpwstr and ui4. The property ID in Pim. Vol is defined in "pimstore. H.
Attribute data is stored in the Union of the cevalunion type. The definition of cevalunion is as follows:
Typedef union _ cevalunion {
Short ival; // @ field cevt_i2
Ushort uival; // @ field cevt_ui2
Long lval; // @ field cevt_i4
Ulong ulval; // @ field cevt_ui4
// @ Field cevt_auto_i4 _
Filetime; // @ field cevt_filetime
Lpwstr; // @ field cevt_lpwstr-PTR to NULL terminated string
Ceblob blob; // @ field cevt_blob-DWORD count, and PTR to bytes
// @ Field cevt_auto_i8
// @ Field cevt_recid
// @ Field cevt_stream
Bool boolval; // @ field cevt_bool
Double dblval; // @ field cevt_r8
} Cevalunion, * pcevalunion;
[Conclusion] In fact, the database is a table, and each row in the table is a record. Each record stores many different types of data. For example, in the oId = 234 record, John (name) is stored), male (gender), Anhui (nationality ).... The top row of the table, that is, the header, stores the property's propid, representing the property type. For example, when creating a database, you can specify the name's propid = 0x0000001f, gender propid = 0x0013001f and so on. When you open a database in the future, you can access the desired Attribute Based on the header, that is, propid, or you can specify the sorting rules based on propid. For example, it is based on the name (0x0000001f) the sorting depends on the place of origin (0x0013001f.
------------------------------------------------------
2. How to read the database
------------------------------------------------------
Step 1: volume of the database to be loaded (volume)
Call cemountdbvolex () to load the specified database file and obtain the guid of the database file, for example, ceguid m_sdbguid.
Step 2: Create a database session
Call cecreatesession (m_sdbguid) to obtain the session handle Handel se;
Step 3: Open the database to be accessed in the volume
Call ceopendatabaseinsession () to open the database.
You can set the parameter "sortorderspecex * psort" of this function to specify the sorting rule. This rule will be followed when you call ceseekdatabaseex () to move the record pointer and access the database.
Note that the access rule of the psort structure must exist in the Database access rule, that is, in the Structure pointed by the psort, the propid in the wnumprops, wkeyflags, and rgpropid [] arrays must be strictly consistent with a sorting rule stored in the database attributes. [Note: when creating a database, a cedbaseinfoex structure is specified, in this structure, cedbaseinfoex: rgsortspecs [16] specifies an array of the sortorderspecex type. That is to say, the database can have up to 16 sorting rules stored in the database ]. When you open the database, you only need to select one of the sorting rules, and the sorting rules must be consistent with the creation of the database, the database does not have a propid. And for EDB, sortorderspecex: wversion must be 2! If these criteria are not met, the ceopendatabaseinsession () function returns invalid_handle_value.
Step 4: Read database records
The database has a record pointer. The cereadrecordprow.x () function reads the record attribute at the record pointer. To direct the record pointer to the record you want to access, that is, to call the ceseekdatabaseex () function to search for the record set of the database and point the record pointer to the search result, there are many search methods, such: enter cedb_seek_ceoid and search based on the specified oid. Enter cedb_seek_beginning to search records whose offset is dwvalue from the first element of the database.
Cereadrecordpropsex () returns the header pointer to the record attribute array. As mentioned above, this array is of the cepropval type. we determine the Data Type of the Attribute Based on propid and then read the attribute value from the cevalunion type.
Specifically, when the cereadrecordpropsex () function is used to read the attribute, the "lplpbuffer" parameter of this function returns the header pointer of the cepropval type array, rgpropid [] stores the propid of the attribute to be read, that is, specifying the attributes to be read by the customer. Because the customer may read many attributes at a time, rgpropid [] is an array, the parameter lpcpropid specifies the number of attributes to be read by the user. When the value is set to 0, it indicates that all attributes of the record are read, and the value of the lpcpropid is assigned when the cereadrecordpropsex () function returns, indicates the number of read attributes.
------------------------------------------------------
3. How to list and read database attributes
------------------------------------------------------
As mentioned above, a volume contains several databases. We can enumerate each database and read its attributes.
Step 1: load data volumes
Call the cemountdbvolex () function.
Step 2: Obtain the enumerated environment handle
Call the cefindfirstdatabaseex () function to obtain a handle that serves as the input to the cefindnextdatabaseex () function and forms an enumeration environment.
Step 3: Enumerate Databases
Call the cefindnextdatabaseex () function to enumerate databases, move database pointers, and obtain the oId of the current database. During enumeration, the while () {} loop is used. The basis for cyclic interruption is database OID = 0. For example:
While (OID = cefindnextdatabaseex (SE, 0 ))! = 0)
{
// Todo: add your code here:
};
Step 4: Read database information
Call the ceoidgetinfoex2 () function to read database information based on the oId. In fact, this function can obtain information about many objects, such as databases, files, paths, and records, based on the oId. When calling this function, the call Stack may be cleared. This is because the array is out of bounds and is caused by no # define EDB.
Database attributes are stored in the ceoidinfoex: infdatabase member. This member is of the cedbaseinfoex type. For more information, see msdn.