views:

1574

answers:

3

I want to create a C# program to provision Windows Mobile devices. I have found MSDN documentation on a function called DMProcessConfigXML, but no instructions on how to use this function.

How can I use this function in my Windows Mobile app? I suspect it has something to do with using pinvoke.

Thanks,
Paul

+1  A: 

I looked at the MSDN and indeed very little information is available. I did some google searching and I found this example. Also this blog entry about a CF open source provisioning application.

Most of the available examples are in C++. If you want to call it from C#, you need to use pinvoke. One great resource is pinvoke.net. Here you can find the signatures you need.

kgiannakakis
+1  A: 

The answers for what to send to DMProcessConfigXML are in MSDN but they are not very easy to understand. You need to look into the Configuration Service Providers documentation.

Basically you give it XML that will either query or set some sort of system parameter and it returns you XML as the result. There is service providers for almost everything on the device. You have to be specific about what you want then I can point you in the documentation and samples that you want.

For example you can use it to query a registry value

You give it the XML:

<wap-provisioningdoc>
   <characteristic type="Registry">
      <characteristic type="HKCU\ControlPanel\Home">
         <parm-query name="Timeout"/>
      </characteristic>
   </characteristic>
</wap-provisioningdoc>

The result XML should look something like:

<wap-provisioningdoc>
   <characteristic type="Registry">
      <characteristic type="HKCU\ControlPanel\Home">
         <parm name="Timeout" value="10000"/>
      </characteristic>
   </characteristic>
</wap-provisioningdoc>

That's a simple example, you can do lots of other things like setting up network settings, setting up mail accounts, etc, etc.

Also, new versions of WM add more CSP's. For example WM6.1 adds the Device Encryption Configuration Service Provider to query / enable / disable full device encryption on a WM6.1 device.

Update: I copied the incorrect example!! DMProcessConfigXml uses OMA Client Provisioning XML not OMA DM Provisioning XML.

Shane Powell
+3  A: 

From managed code, you can call ConfigurationManager.ProcessConfiguration found in the Microsoft.WindowsMobile.Configuration namespace. msdn Here is sample code:

XmlDocument configDoc = new XmlDocument();
configDoc.LoadXml(
    "<wap-provisioningdoc>"+
    "<characteristic type=\"BrowserFavorite\">"+
    "<characteristic type=\"Microsoft\">"+
    "<parm name=\"URL\" value=\"http://www.microsoft.com\"/&gt;"+
    "</characteristic>"+
    "</characteristic>"+
    "</wap-provisioningdoc>"
    );
ConfigurationManager.ProcessConfiguration(configDoc, false);

No need to P/Invoke.

mjf
Thanks, that's exactly what I needed.
Symmetric