Sdílet prostřednictvím


ISyncSession::Start

Starts a synchronization session.

HRESULT Start( 
  CONFLICT_RESOLUTION_POLICY resolutionPolicy,
  SYNC_SESSION_STATISTICS * pSyncSessionStatistics);

Parameters

  • resolutionPolicy
    [in] The conflict resolution policy to be used for the synchronization session.
  • pSyncSessionStatistics
    [in, out, unique] Returns statistics about the synchronization session.

Return Value

  • S_OK

  • E_OUTOFMEMORY

  • E_INVALIDARG

  • SYNC_E_INVALID_OPERATION when Start is called more than one time.

  • SYNC_E_INTERNAL_ERROR

  • Change applier error codes

  • Provider-determined error codes

Example

HRESULT Synchronize(ISyncProvider* pProvSrc, ISyncProvider* pProvDest)
{
    HRESULT hr = E_UNEXPECTED;

    IApplicationSyncServices* pSvc = NULL;
    hr = CoCreateInstance(CLSID_SyncServices, NULL, CLSCTX_INPROC_SERVER, 
        IID_IApplicationSyncServices, (void**)&pSvc);
    if (SUCCEEDED(hr))
    {
        ISyncSession* pSession = NULL;
        hr = pSvc->CreateSyncSession(pProvDest, pProvSrc, &pSession);
        if (SUCCEEDED(hr))
        {
            SYNC_SESSION_STATISTICS syncStats;
            // Arbitrarily choose "destination wins" conflict resolution.
            hr = pSession->Start(CRP_DESTINATION_PROVIDER_WINS, &syncStats);
            if (SUCCEEDED(hr))
            {
                // Display the session statistics to the user.
                CString strMsg;
                strMsg.Format(L"%d changes succeeded.\n%d changes failed.", syncStats.dwChangesApplied,
                    syncStats.dwChangesFailed);
                MessageBox(NULL, strMsg.GetString(), L"Synchronization Statistics", MB_ICONINFORMATION);
            }

            pSession->Release();
        }

        pSvc->Release();
    }

    return hr;
}

See Also

Reference

ISyncSession Interface
CONFLICT_RESOLUTION_POLICY Enumeration
SYNC_SESSION_STATISTICS Structure