Flushing a Database Volume

< BACK  NEXT >
[oR]

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 pceguid Pointer to the CEGUID for the open database volume to be flushed
BOOL Return Value Returns 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 pceguid Pointer to a CEGUID value, which is set to invalid for the first call
LPWSTR lpBuf Pointer to a string buffer that receives the CDB file and path name
DWORD dwNumChars Size of lpBuf in characters
BOOL Return Result Returns 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; 

< BACK  NEXT >


Windows CE 3. 0 Application Programming
Windows CE 3.0: Application Programming (Prentice Hall Series on Microsoft Technologies)
ISBN: 0130255920
EAN: 2147483647
Year: 2002
Pages: 181

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net