Flushing a Database Volume

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");

Table 4.3. CeFlushDBVol—Flushes cached writes
CeFlushDBVol 
PCEGUID pceguidPointer to the CEGUID for the open database volume to be flushed
BOOL Return ValueReturns TRUE if database volume is flushed

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 Volumes

The 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 Volumes
void Listing4_2()
{
  CEGUID ceguid;
  TCHAR szVolumeName[MAX_PATH + 1];
  CREATE_INVALIDGUID(&ceguid);
  while(CeEnumDBVolumes(&ceguid, szVolumeName, MAX_PATH))
  {
    cout ≪ _T("Mounted vol: ")
         ≪ szVolumeName ≪ endl;
  }
}

Table 4.4. CeEnumDBVolumes—Lists all mounted volumes
CeEnumDBVolumes 
PCEGUID pceguidPointer to a CEGUID value, which is set to invalid for the first call
LPWSTR lpBufPointer to a string buffer that receives the CDB file and path name
DWORD dwNumCharsSize of lpBuf in characters
BOOL Return ResultReturns TRUE if enumeration was successful

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;

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.239.46