All writes to a database volume are cached to improve performance. Changes to databases held in the cache will be lost if the device is reset, unless the cache is written out to the object store or storage device. Flushing occurs when the database volume is unmounted, or when the CeFlushDBVol function is called. if(CeFlushDBVol(&pceguid)) cout _T("Flushed!"); else cout _T("Could not flush database volume");
You should not call CeFlushDBVol too frequently since the performance of your application will degrade. Call it after making significant changes to databases, especially if you are keeping the database volume mounted for a long period of time. Listing Mounted Database VolumesThe CeEnumDBVolumes function can be used to list the database volumes mounted by all applications running on a Windows CE device (Listing 4.2). Listing 4.2 Lists Mounted Database Volumesvoid Listing4_2() { CEGUID ceguid; TCHAR szVolumeName[MAX_PATH + 1]; CREATE_INVALIDGUID(&ceguid); while(CeEnumDBVolumes(&ceguid, szVolumeName, MAX_PATH)) { cout _T("Mounted vol: ") szVolumeName endl; } }
The pceguid argument must be set to an invalid value for the first call, and calling the CREATE_INVALIDGUID macro does this by putting "21" values in each byte of the CEGUID. The function returns the CEGUID of an open database volume, and this CEGUID value is passed into the next CeEnumDBVolumes call to get information on the next mounted database volume. The enumeration will generally return "SystemHeap" as the first mounted database volume this represents the default database volume contained in the object store and has a special CEGUID with "0" values in each byte. The pceguid returned from calling CeEnumDBVolumes can be tested for being the system heap by using the CHECK_SYSTEMGUID macro. if(CHECK_SYSTEMGUID(&ceguid)) cout _T("Object Store database volume!") endl;
|