Share via


IProviderSyncServices::CreateReplicaKeyMap

Creates an IReplicaKeyMap for a specified replica.

HRESULT CreateReplicaKeyMap( 
  const BYTE *pbReplicaId,
  IReplicaKeyMap **ppReplicaKeyMap);

Parameters

  • pbReplicaId
    [in] The ID of the replica that owns this replica key map.
  • ppReplicaKeyMap
    [out] Returns the newly created replica key map object.

Return Value

  • S_OK

  • E_OUTOFMEMORY

  • E_POINTER

  • SYNC_E_INVALID_OPERATION when this object is not initialized.

  • SYNC_E_ID_FORMAT_MISMATCH when the ID specified by pbReplicaId is not in the format specified by the ID format schema that is used to initialize this object.

Remarks

The replica key map object maps between replica IDs and 4-byte keys and is required for creating synchronization knowledge. Because of the repeated need for replica IDs in the synchronization metadata, Sync Framework uses a table to map replica IDs down to 4-byte keys and uses the replica keys throughout the synchronization metadata instead of replica IDs.

Example

The following example uses IProviderSyncServices to create several objects. The example stores the objects for later use.

IProviderSyncServices* pProvSvc;
hr = GetProviderSyncServices(&c_idParams, &pProvSvc);
if (SUCCEEDED(hr))
{
    IReplicaKeyMap* pReplicaKeyMap = NULL;
    hr = pProvSvc->CreateReplicaKeyMap((BYTE*)&guidReplicaID, &pReplicaKeyMap);
    if (SUCCEEDED(hr))
    {
        hr = SetReplicaKeyMap(pReplicaKeyMap);
        if (SUCCEEDED(hr))
        {
            ISyncKnowledge* pKnowledge = NULL;
            hr = pProvSvc->CreateSyncKnowledge(0, pReplicaKeyMap, &pKnowledge);
            if (SUCCEEDED(hr))
            {
                hr = SetKnowledge(pKnowledge);
                if (SUCCEEDED(hr))
                {
                    IForgottenKnowledge* pForgottenKnowledge = NULL;
                    hr = pProvSvc->CreateForgottenKnowledge(pReplicaKeyMap, &pForgottenKnowledge);
                    if (SUCCEEDED(hr))
                    {
                        hr = SetForgottenKnowledge(pForgottenKnowledge);

                        pForgottenKnowledge->Release();
                    }
                }

                pKnowledge->Release();
            }
        }

        pReplicaKeyMap->Release();
    }
    pProvSvc->Release();
}

See Also

Reference

IProviderSyncServices Interface