Object Identifiers

Each object in the object store—whether a directory, file, database, or database record—is associated with a unique object identifier. The system generates an object identifier for each object when it is created. The most common use of object identifiers is accessing databases and their records.

Object type Where to obtain the object identifier
Directory or file The dwOID member of WIN32_FIND_DATAW from FindFirstFile or FindNextFile.

The dwOID member of BY_HANDLE_FILE_INFORMATION from GetFileInformationByHandle.

Database Return value of CeCreateDatabase or CeFindNextDatabase.
Database record Return value of CeSeekDatabase, CeReadRecordProps, or CeWriteRecordProps.

Another important use of object identifiers is to obtain information on any object in the store. To accomplish this, a Windows CE-based application calls the CeOidGetInfo function and supplies the object identifier in the parameter of type CEOID. CeOidGetInfo returns the object data in a CEOIDINFO structure. This structure's wObjType member contains a flag that indicates the object type. The data in the structure depends on the type of object. For example, if the object is a database record, the CEOIDINFO structure's wObjType member contains the flag OBJTYPE_RECORD, indicating that the data for the object consists of a CERECORDINFO structure. If there is no valid object for the object identifier the return value of CeOidGetInfo is FALSE.

The following code example shows how to use the object identifier to obtain the object type of any object in the object store.

CEOID WceObjID;            // object identifier
CEOIDINFO WceObjInfo;      // structure that contains object info 
TCHAR szMsg[MAX_STRING];   // string to display with object info
... 
if (CeOidGetInfo(WceObjID, &WceObjInfo)) 
{ 
   switch (WceObjInfo.wObjType) 
   {
      case OBJTYPE_FILE:
         wsprintf(szMsg, TEXT("Object is a file: %s"), 
                         WceObjInfo.infFile.szFileName); 
         break;
      case OBJTYPE_RECORD:
         wsprintf(szMsg, TEXT("Object is a record"));
         break;
      case OBJTYPE_DATABASE: 
         wsprintf(szMsg, TEXT("Object is a database: %s"), 
                         WceObjInfo.infDatabase.szDbaseName); 
         break;
      case OBJTYPE_DIRECTORY: 
         wsprintf(szMsg, TEXT("Object is a directory: %s"), 
                         WceObjInfo.infDirectory.szDirName); 
         break;
      default:
         // handle error ...
         break;
   }
}