Freigeben über


Mounting and Unmounting a Database Volume (Windows CE 5.0)

Send Feedback

To create and use a database volume with Windows CE 2.10 and later, you first must mount, or open, the volume. This does not include the object store, which is always mounted and identified by a system CEGUID. After all operations are complete, you must unmount, or close, the volume. Mounting and unmounting add a level of complexity to your database programming, but allow you to store a database elsewhere on a device other than the object store. You still can use the original database API in Windows CE 2.10 and later to gain access to a database in the object store. However, the earlier API exists for backward compatibility only; every new application should use the new API.

Call the CeMountDBVol function to mount a volume that can store Windows CE-based databases on any file system, including the object store or an installed file system. CeMountDBVol acts as a specialized version of the CreateFile function; instead of opening or creating a generic file, CeMountDBVol opens or creates a database volume. CeMountDBVol accepts the location of the file that is the database volume and returns a PCEGUID structure. Functions that are designed to manipulate mounted database volumes use PCEGUID as a handle to identify a given volume.

Call the CeUnmountDBVol function to unmount a database volume. Like the CloseHandle function, CeUnmountDBVol returns to the system any resources that the database volume was using. The act of unmounting flushes the database volume so you do not have to call CeFlushDBVol to save any data. Windows CE automatically flushes the cache on a periodic basis; in the event of a power failure or reset you will lose only data altered since the last cache flush. Also, a power failure or reset does not alter the volume itself.

Note that more than one process can mount the same database volume. Windows CE keeps track of how many processes have access to a given database volume. When the last process unmounts the database, Windows CE closes the file.

The following code example shows how to unmount a database volume. For an example that shows how to mount a database volume, see Mounted Database Example.

void UnmountingDBs (PCEGUID pceguid)
{
  TCHAR szMsg[100];

  if (!CeUnmountDBVol (pceguid))
  {
    wsprintf (szMsg, TEXT("Failed unmounting the database."));

    // Your error-handling code goes here.
  }
} // End of UnmountingDBs example code

See Also

Databases

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.