ISyncSession::Start
启动同步会话。
HRESULT Start(
CONFLICT_RESOLUTION_POLICY resolutionPolicy,
SYNC_SESSION_STATISTICS * pSyncSessionStatistics);
参数
- resolutionPolicy
[in] 要用于同步会话的冲突解决策略。
- pSyncSessionStatistics
[in, out, unique] 返回有关同步会话的统计信息。
返回值
S_OK
E_OUTOFMEMORY
E_INVALIDARG
如果多次调用了 Start,则返回值为 SYNC_E_INVALID_OPERATION。
SYNC_E_INTERNAL_ERROR
变更应用方错误代码
提供程序确定的错误代码
示例
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;
}
请参阅
参考
ISyncSession 接口
CONFLICT_RESOLUTION_POLICY 枚举
SYNC_SESSION_STATISTICS 结构