Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

The service manager automatically detects object changes and deletions by comparing the list of handles returned during enumeration with the handles loaded from the service manager's persistent file. Before starting an enumeration process, the service manager does the following:

  1. Marks a bit for each handle stored in Repl.dat.

  2. Calls IReplStore::FindFirstItemand IReplStore::FindNextItem.

  3. Performs a binary search on the handles in Repl.dat each time one of these methods returns a new handle to find a handle representing the same object.

  4. If no matching handle is found, it creates a new object on the desktop store.

  5. If a matching handle is found, it clears the bit from the handle in Repl.dat and calls IReplStore::IsItemChangedto see if the object has changed since the last synchronization.

  6. If the object has changed, it calls IReplStore::CopyObjectto copy the data from the returned handle into the handle that is saved in Repl.dat.

  7. Calls IReplStore::IsItemReplicatedto see if it should send the object to the Windows Mobile device.

All handles in Repl.dat that remain marked once enumeration is complete represent deleted objects.

To speed up enumeration, the desktop provider can detect and report desktop changes to the service manager in real time. To do so, the desktop provider and service manager perform the following actions.

  1. The service manager calls IReplNotify::OnItemNotifyto inform the desktop provider of an object's status.

  2. The desktop provider passes RNC_MODIFIED for a modified object, RNC_CREATED for a created object, and RNC_DELETED for a deleted object.

  3. The desktop provider passes a handle to the object so the service manager can search the persistent file for the corresponding device object.

The following illustration shows the sequence of real-time notification calls.

If the desktop provider detects that the desktop application has closed, it calls IReplNotify::OnItemNotifywith RNC_SHUTDOWN. The service manager responds by unloading the desktop provider and updating the status display.

The following code examples show how to implement IReplStore::IsItemChangedand IReplStore::IsItemReplicated.

Copy Code
STDMETHODIMP_(BOOL) CStore::IsItemChanged
(
   HREPLFLD  hFolder,   // handle of folder or container that
stores object
   HREPLITEM hItem,  // handle of object
   HREPLITEM hItemComp  // handle of object used for comparison
)
{
   CFolder *pFolder   = (CFolder*)hFolder;
   CItem   *pItem	 = (CItem*)  hItem;
   CItem   *pItemComp = (CItem*)  hItemComp;
   BOOL	 fChanged  =  FALSE;

   if (pItemComp)
	 fChanged = CompareFileTime (&pItem->m_ftModified,
							
&pItemComp->m_ftModified);
   else
   {
	 FILETIME ft;

	 // Read modification time stamp from object into ft.
	 // Compare with the time stamp in the object.
	 fChanged = CompareFileTime (&pItem->m_ftModified,
&ft);
   }
   return fChanged;
}

STDMETHODIMP_(BOOL) CStore::IsItemReplicated
(
   HREPLFLD  hFolder,   // handle of folder or container that
stores object
   HREPLITEM hItem,  // handle of object
)
{
   CFolder *pFolder = (CFolder*)hFolder;
   CItem   *pItem   = (CItem*)  hItem;

   // hItem can be NULL.
   if (pItem == NULL)
	 return TRUE;

   // Search for the item. Return FALSE if not found.
   // ...

   // Check if pItem should be replicated by using information
   // stored both in pFolder & pItem. If so, return TRUE.
   // ...

   return FALSE;
}

See Also