次の方法で共有


Mounting and Unmounting a Database Volume (Windows Embedded CE 6.0)

1/6/2010

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 on a device other than the object store. You can still 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 (CEDB) function to mount a volume that can store Windows Embedded 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 volume.

Call the CeUnmountDBVol (CEDB) 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 need to call the CeFlushDBVol (CEDB) function to save data. Windows Embedded CE automatically flushes the cache on a periodic basis. If there is a power failure or a reset, you lose only data altered since the last cache flush. A power failure or reset does not alter the volume itself.

More than one process can mount the same database volume. Windows Embedded CE keeps track of how many processes have access to a given database volume. When the last process unmounts the database, Windows Embedded 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.
   }
}

See Also

Concepts

CEDB Database Support