DMProcessConfigXML (aygshell)
Last changed: -131.107.0.74

.
Summary
Send XML to Windows Mobile to provision a device for all kinds of different aspects of configuration.

C# Signature:

[DllImport("aygshell.dll", CharSet = CharSet.Unicode)]
static unsafe extern CONFIG_E DMProcessConfigXML(string pszWXMLin, CFGFlags dwFlags, out char * ppszwXMLout);

User-Defined Types:

public enum CFGFlags : uint {
     Process = 0x0001,
     Metadata = 0x0002,
}

public enum CONFIG_E : uint {
     Ok = 0x00000000,
     ObjectBusy = 0x80042001,
     CancelTimeout = 0x80042002,
     EntryNotFound = 0x80042004,
     ProcessingCanceled = 0x00042005,
     CspException = 0x80042007,
     TransactioningFailure = 0x80042008,
     BadXml = 0x80042009,
}

Alternative Managed API:

Microsoft.SmartDevice.Connectivity.Device.ProvisionDevice(string, Device.ConfigActions), although it is a desktop managed method and only works remotely, whereas this P/Invoke can be executed directly on the device.

Notes:

It is very important to properly dispose of the char* buffer that is created by this call. See the sample code for a wrapper method that can make this easy.

Andrew Arnott has an MSDN blog tag that discusses various aspects of provisioning devices: http://blogs.msdn.com/andrewarnottms/archive/tags/provisioning/default.aspx

Sample Code:

[DllImport("coredll.dll", EntryPoint = "??_V@YAXPAXABUnothrow_t@std@@@Z")] static extern void DeleteArray(IntPtr ptr, IntPtr junk); public static CONFIG_E DMProcessConfigXML(      string xml, CFGFlags flags, out string resultXml) {      CONFIG_E result;      unsafe {      char* xmlOutPointer;      result = DMProcessConfigXML(xml, flags, out xmlOutPointer);      resultXml = new string(xmlOutPointer);      DeleteArray((IntPtr)xmlOutPointer, IntPtr.Zero);      }      return result; } Documentation: DMProcessConfigXML@msdn on MSDN