2010年10月15日 星期五

Enumerate database in volume

As I said in [Windows Mobile (CE) Database Study], the terminology of CEDB and EDB is almost killing me. The topic is enumerate  tables in database, if using all other common database engines.

I cannot find any document descripts CEDB and EDB which one used in Windows Mobile 6.1 (my test device). But I cannot use EDB only APIs on my develop environment (VS2008 + WM 6.1 SDK) , so the sample code here is using CEDB.

Here is the code piece, follow the sample code in [Enumerate DB Volumes], we got the DB volume’s CEGUID (in variable ‘guid’) and then try to enumerate all database (tables) in that volume.

HANDLE hFind = CeFindFirstDatabaseEX(&guid, 0);
CEOID oid = 0;
while ((oid = CeFindNextDatabaseEx(hFind, NULL)) != 0) 
{
        CEOIDINFOEX oidinfo;
        memset(&oidinfo, 0, sizeof(CEOIDINFOEX));
        oidinfo.wVersion = CEOIDINFO_VERSION;

        if ((CeOidGetInfoEx2(&guid, oid, &oidinfo))
        {
                /// TODO: print out oidinfo.infDatabase.szDbaseName
        }
}
CloseHandle(hFind);

Back to enumeration, you can use CREATE_INVALIDGUID to initialize variable 'guid’, then the code will enumerate all database (tables) in all mounted volume (I am not sure the order)..

And you can specified a PCEGUID in the second parameter of CeFindNextDatabaseEx() function to get the volume’s GUID which the database belongs to.

Below is the enumeration of my device, just for reference.

VOL: \Documents and Settings\default.vol
        ScheduleU
        ScheduleS
        ScheduleGroupU
        ScheduleGroupS
VOL: \ReplStorVol
        ReplStor
VOL: \mxip_notify.vol
        DB_notify_queue
        DB_notify_events
VOL: \mxip_swmgmt.vol
        SwMgmtMetadataStore
VOL: \cemail.vol
        fldr3100001d
        pmailVolumes
        pmailNamedProps
        pmailMsgClasses
        pmailOldTables
        pmailMsgs
        pmailFolders
VOL: \mxip_system.vol
        \ConfigMetabase
VOL: \mxip_lang.vol
        \MetabaseOptions
        \MetabaseLabels

沒有留言:

張貼留言