Overview of Registering a Synchronization Provider

After you build your synchronization provider, we recommend that you register it with Windows 7. By registering your provider, the Windows synchronization system will recognize it and be able to locate it when a synchronization session begins. The name of your provider and the format of the data it represents will appear in a drop-down selection box in Windows Device Stage, the new Windows 7 experience for portable device users.

Synchronization providers are registered through the ISyncProviderRegistration interface, a native-only interface that can be accessed through the PInvoke method. The provider registration system functions basically as a large property store. The values in the property store are populated by the information set in the SyncProviderConfiguration structure when the CreateSyncProviderRegistrationInstance method is called. You also have the option of adding additional properties to the property store if your provider requires it.

To register your provider, you must supply the Class ID that is used to create your provider's object, and a unique Instance ID for each content type that your provider supports to the SyncProviderConfiguration structure. If your provider is a simple provider, it will support only one content type, such as contacts. If your provider supports several content types, such as contacts, tasks, and notes, it must be registered once for each content type with a unique Instance ID for each registration entry.

In addition to the Class ID and Instance ID properties which must be included, you can add additional properties and values to the property store.

For a complete reference of all enumerations, interfaces, structures, error codes, and property keys provided for developers to register a synchronization provider, see the Windows Sync Registration Reference section.

The following example shows the minimum amount of code necessary to register a simple synchronization provider that supports one content type. In this example, a SyncProviderConfiguration structure providerConfig is created and the provider's Class ID, Instance ID, and the content type GUID for "contacts" are set in the structure. A registration instance is created by passing providerConfig, and a pointer to an ISyncProviderInfo interface (spProviderInfo) to the CreateSyncProviderRegistrationInstance method of the ISyncProviderRegistration interface (represented by spProviderRegistration). spProviderInfo is also passed when instantiating an IPropertyStore interface, and the provider's property store is committed and the provider is fully registered and discoverable as soon as the spProviderInfo.Commit method is called.

SyncProviderConfiguration providerConfig = {(SYNC_PROVIDER_CONFIGURATION_VERSION)};

// Set the CLSID used to create the provider's object.
providerConfig.clsidProvider = CLSID_MYPROVIDER;

// Set the Unique id for this provider on this computer. 
providerConfig.guidInstanceId = guidProviderInstanceId;

// Set the content type of the provider (for example, Contacts).
providerConfig.guidContentType = SERVICE_Tasks;

providerConfig.dwCapabilities = SPC_DEFAULT;

CComPtr<ISyncProviderInfo> spProviderInfo;
spProviderRegistration->CreateSyncProviderRegistrationInstance(&amp;providerConfig,
       &amp;spProviderInfo);     
CComQIPtr<IPropertyStore> spProviderPropStore(spProviderInfo);

// This method commits the provider's property store. At this time
// the provider becomes fully registered and discoverable.
spProviderInfo->Commit(); 

Windows Sync Overview

Windows Sync Registration Reference