views:

1272

answers:

3

I am developing a desktop app which manages contact information and I want to be able to have it sync with the contacts list on Windows Mobile devices. Which namespaces/APIs do I need to understand to do this? I would prefer something in .NET compact framework, but I can do Win32 as well. I am looking for an approach that is completely stand alone, i.e. not dependent on a separate app such as Outlook. Thanks

+1  A: 

ActiveSync does not have a managed API. There is a sample called "stockpor" in the ActiveSync SDK folder (by default it's at C:\Program Files\Windows CE Tools\wce500\Windows Mobile 5.0 Pocket PC SDK\Activesync\Activesync stock portfolio sample) that gives you an example of how to do custom item synchronization.

EDIT: A second option would be to use POOM for the device side, and create a custom RAPI DLL that you could interact with (it's not advised to try to directly open the contacts database, as the record fomat is not guaranteed to stay the same across WinMo versions). You would have to do your own conflict resolution, etc. but it might be easier to get at the on-device contact info that way.

ctacke
+2  A: 

If you can work with the most recent compact framework then you can use the WindowsMobile Class Library.

If you have to work with an older version of the framework or want to support older hardware you can access the native ActiveSync API with Interop. All of the C++ APIs can be accessed through either Interop/PInvoke or COM Interop. An example is here.

Arnshea
A: 

Also consider looking at Microsoft SyncFramework. Sync is a far harder problem than people realise and building a solution that caters to all the edge cases can be very difficult. IIRC they even have examples on syncing from Outlook to a Pocket PC.

If you do decide to go the RAPI route OpenNETCF have a nice RAPI C# library see here.

Nic Strong