Windows CE assigns each object that is created within a volume a unique Windows CE object identifier. Each Windows CE object identifier is unique within a given volume, but not across multiple volumes. Windows CE also gives all volumes a Windows CE globally unique identifier (CEGUID). The object store also has a CEGUID, which is predefined. The most common use for a Windows CE object identifier is to access object data, such as a database record, and to obtain object data. Use the CEGUID in conjunction with the Windows CE object identifier to uniquely reference each record and object. The following table shows where to obtain the Windows CE object identifier for the various types of objects in the object store.
Object type |
Where to obtain the Windows CE object identifier |
Directory or file | The dwOID member of the WIN32_FIND_DATA structure, which is returned by the FindFirstFile and FindNextFile functions. Also in the dwOID member of the BY_HANDLE_FILE_INFORMATION structure, which is returned by the GetFileInformationByHandle function. |
Database | The return value of the CeCreateDatabaseEx or CeFindNextDatabaseEx function |
Database record | The return value of the CeSeekDatabase, CeReadRecordPropsEx, or CeWriteRecordProps function |
Mounted database volume | The CeMountDBVol and CeEnumDBVolume functions return the CEGUID of the mounted database volume. |
Use the CeOidGetInfoEx function to return object data associated with the Windows CE object identifier. This function returns object data in a CEOIDINFO structure. The CEOIDINFO wObjType member contains a flag indicating the object type, such as OBJTYPE_DATABASE for a database object, and also identifies which object structure to use to access the data. CEOIDINFO also contains a member that returns data on either a file, directory, database, or database record. These values correspond to the type of object that is indicated by the wObjType member. For example, using CeOidGetInfoEx on a mounted database volume returns the database name, type identifier, number of records, database size, and sort order in a CEDBASEINFO structure, as well as the OBJTYPE_DATABASE value.
The following code example shows how to retrieve data from the object store or mounted volume by using the Windows CE object identifier.
void UsingCeOidGetInfo (void)
{
CEOID CeOid; // Object identifier
PCEGUID pceguid; // GUID of the mounted volume
CEOIDINFO CeObjectInfo; // Structure into which to retrieve
// object data
TCHAR szMsg[200]; // String to use with object data
// Assign to pceguid the CEGUID of the mounted volume
// on which the object resides.
// ...
// Assign to CeOid the OID of the object about which
// you want to get data.
// ...
if (CeOidGetInfoEx (pceguid, CeOid, &CeObjectInfo))
{
switch (CeObjectInfo.wObjType)
{
case OBJTYPE_FILE:
wsprintf (szMsg, TEXT("Object is a file: %s"),
CeObjectInfo.infFile.szFileName);
break;
case OBJTYPE_DIRECTORY:
wsprintf (szMsg, TEXT("Object is a directory: %s"),
CeObjectInfo.infDirectory.szDirName);
break;
case OBJTYPE_DATABASE:
wsprintf (szMsg, TEXT("Object is a database: %s"),
CeObjectInfo.infDatabase.szDbaseName);
break;
case OBJTYPE_RECORD:
wsprintf (szMsg, TEXT("Object is a record"));
break;
case OBJTYPE_INVALID:
wsprintf (szMsg,
TEXT("The object store does not contain a valid ")
TEXT("object that has this object identifier."));
break;
default:
wsprintf (szMsg, TEXT("Object is of unknown OBJTYPE"));
break;
}
}
else
{
// Your error-handling code goes here.
if (GetLastError () == ERROR_INVALID_HANDLE)
wsprintf (szMsg, TEXT("Invalid Object ID"));
else
wsprintf (szMsg, TEXT("Unknown error"));
}
} // End of UsingCeOidGetInfo code