Tuesday, June 19, 2007

Provisioning XML with CSP's

A couple of my other posts mentioned using Configuration Service Providers but I didn't mention how to actually provision the XML once created in the correct format.

Doing this is easy in CF2 and WM5 you can use the new assembly which comes with WM5 SDK Microsoft.WindowsMobile.Configuration.dll. ie:

using Microsoft.WindowsMobile.Configuration;

//xmlDoc is of type XmlDocument which contains a valid CSP schema.
ConfigurationManager.ProcessConfiguration(xmlDoc, false);

Of course this is not so easy on pre-WM5 as the *.WindowsMobile.* assembly range of API's only work on WM5 and later.

You can P/Invoke DMProcessConfigXML or you could use InTheHand.WindowsMobile.Configuration. in the hand have written a managed wrapper that will provision your XML on pre Windows Mobile 5 devices and I believe it's free. ie:

using InTheHand.WindowsMobile.Configuration;

//xmlDoc is of type XmlDocument which contains a valid CSP schema.
ConfigurationManager.ProcessConfiguration(xmlDoc, false);

No comments: