Someone in the newsgroups recently asked about finding the database that sets up ActiveSync to run when a cable is plugged into a device. My first thought is to simply enumerate the user notifications, which I showed in a recent post, Windows CE: Enumerating User Notifications, and look for the RS232 detected event which launches repllog.exe. But then I thought that it might be interesting to enumerate the databases themselves.
The following function, EnumerateDataBases(), will output the CEDB databases, their size and the number of records that they store. This function uses CeFindFirstDatabaseEx() and CeFindNextDatabaseEx() to find the databases. Then it uses CeOidGetInforEx() to get the database information.
I don’t dig further into the database records for two reasons; the contents of the records are not well documented and the notification database can be enumerated by enumerating the user notifications.
void EnumerateDataBases()
{
                HANDLE FoundDB;
                CEOID CurrentOID;
 
                FoundDB = CeFindFirstDatabaseEx(NULL, 0);
                if(FoundDB == INVALID_HANDLE_VALUE)
                {
                                RETAILMSG( 1, (TEXT("No Databases found\n")));
                }
                else
                {
                                while( CurrentOID = CeFindNextDatabaseEx( FoundDB, 0 ) )
                                {
                                                CEOIDINFO OIDInfo;
                                                RETAILMSG( 1, (TEXT("Database found\n")));
                                                if(CeOidGetInfoEx(NULL, CurrentOID, &OIDInfo))
                                                {
                                                                if(OIDInfo.wObjType == OBJTYPE_DATABASE)
                                                                {
                                                                                RETAILMSG(1, (TEXT(" Database: %s\n"), OIDInfo.infDatabase.szDbaseName ));
                                                                                RETAILMSG(1, (TEXT(" Size: %d\n"), OIDInfo.infDatabase.dwSize ));
                                                                                RETAILMSG(1, (TEXT(" Records: %d\n"), OIDInfo.infDatabase.wNumRecords ));
                                                                }
                                                                else
                                                                                RETAILMSG( 1, (TEXT("Failed to get info for this database\n")));
                                                }
                                }
                                CloseHandle( FoundDB );
                }
}
 
The output looks like this:
Database found
 Database: RecycleData
 Size: 356
 Records: 0
Database found
 Database: DB_notify_queue
 Size: 520
 Records: 1
Database found
 Database: DB_notify_events
 Size: 920
 Records: 6
The user notification database is DB_notify_events which contains 6 records. If you try enumerating the user notifications, the result is the same, 6 records. Of course your results may be different, but the number of records should match the number of user notifications.
Copyright © 2008 – Bruce Eitman
All Rights Reserved