DMProcessConfigXML CM_MAPPINGS



Hi all

I am using the following code to try to add a URL exception to the networks
list on my PocketPC 2003.

================
public enum ConfigFlag : uint
{
/// <summary>
/// The configuration management service and the
/// Configuration Service Providers (CSPs) process
/// the input data.
/// </summary>
Process = 1,

/// <summary>
/// The configuration management service gathers
/// and returns metadata for any XML parm elements
/// it encounters.
/// </summary>
Metadata = 2
}

public class ConfigWrapper
{
[DllImport("aygshell.dll")]
private extern static UInt32 DMProcessConfigXML(string xmlIn, UInt32
flag, out IntPtr xmlOutPtr);

[DllImport("coredll.dll")]
private extern static IntPtr LocalFree(IntPtr hMem);

public static string ProcessXml(string xml)
{
return ProcessXml(xml, ConfigFlag.Process);
}

/// <summary>
/// This function wraps acts as a managed interface to the
/// DMProcessConfigXML in Pocket PC 2003+ and Smartphone 2002+
/// The DMProcessConfigXML function grants remote access to the
/// configuration management functionality of the mobile device.
/// This function enables the submission of Extensible Markup
/// Language (XML) information that causes the settings of a
/// mobile device to change. See "Configuration Service Providers"
/// in the API for details on the XML schema.
/// </summary>
/// <param name="xml">
/// String of valid XML containing configuration data
/// </param>
/// <param name="flag">
/// Action flag (see ConfigFlag for details)
/// </param>
/// <returns>
/// String of valid XML containing the result of this operation
/// </returns>
public static string ProcessXml(string xml, ConfigFlag flag)
{
IntPtr xmlOutPtr;
string xmlOutStr;
long result;

result = DMProcessConfigXML(xml, (uint)flag, out xmlOutPtr);

// marshal the output string
xmlOutStr = Marshal.PtrToStringUni(xmlOutPtr);

// free the memory allocated by the API
LocalFree(xmlOutPtr);

// throw an exception if an error code was returned
if (result != 0)
{
throw new ArgumentException(String.Format(
"DMProcessConfigXML returned error code {0}", result),
xml);
}

return xmlOutStr;
}
}
================================


I have also tried this



=================================
internal static class XmlConfig
{
[DllImport("aygshell.dll")]
private static extern int DMProcessConfigXML(string pszWXMLin, int
dwFlags, IntPtr ppszwXmlOut);

[DllImport("coredll.dll")]
private static extern void free(int buffer);

unsafe static public void ProcessXml(string Xml)
{
fixed (int* OutPtr = new int[1])
{
IntPtr outptr = (IntPtr)OutPtr;
int result = DMProcessConfigXML(Xml, 1, outptr);
if (result != 0)
throw new Exception("Could not set network preferences");
else
free(*OutPtr);
}
}
==============================



The XML being sent is as follows:
<wap-provisioningdoc>

<characteristic type="CM_Mappings">

<characteristic type="1005">

<param name="pattern"
value="http://myserver.com/MyWebServiceFolder/SyncService.asmx"; />

<param name="network" value="{A1182988-0D73-439e-87AD-2A5B369F808B}" />

</characteristic>

</characteristic>

</wap-provisioningdoc>







If I manually add an exception then my app does not invoke the GPRS dialler
and connects to the server through the WORK connection, if I remove this
manual exception and try to add it using either of the two above methods the
dialler dialog still appears and the Internet connection is used. As far as
I can see from all sources on the web I am doing this correctly, but it just
isn't working. Can anyone help me with this? I saw Peter Foot asking how
to do the same thing quite some time ago so I hope he at least has achieved
his goal and might share the answer :-)





Thanks in advance!





Pete


.



Relevant Pages

  • Re: DMProcessConfigXML CM_MAPPINGS
    ... documentation says is used for the standard mappings - and user mappings start at 0x1000000. ... Also while the first code example is 99% correct, you should free the returned string pointer with free not LocalFree e.g. ... /// Configuration Service Providers process ... /// and returns metadata for any XML parm elements ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: DMProcessConfigXML CM_MAPPINGS
    ... Also while the first code example is 99% correct, you should free the returned string pointer with free not LocalFree e.g. ... /// Configuration Service Providers process ... /// and returns metadata for any XML parm elements ... private extern static UInt32 DMProcessConfigXML(string xmlIn, UInt32 flag, out IntPtr xmlOutPtr); ...
    (microsoft.public.dotnet.framework.compactframework)
  • RE: Wanting to read XML blob from configuration
    ... Get the XML for a section. ... As I said I think the .NET model is brain ... NET 2.0 configuration model? ... a section to be avalid in .net application config file. ...
    (microsoft.public.dotnet.framework)
  • Re: app.config custom types
    ... Keep in mind my sample is not a direct KB on "how to implement a custom ... you gotta write the glue code which takes XML and converts it to a real ... This entry shows how to write a custom configuration handler (based on ...
    (microsoft.public.dotnet.languages.csharp)
  • XML Serialization problems related to framework versions
    ... I get an exception when trying to deserialize a simple configuration ... .NET 1.0 XML assembly. ... at System.Reflection.Assembly.nLoad(AssemblyName fileName, String ... Boolean stringized, Evidence assemblySecurity, StackCrawlMark& ...
    (microsoft.public.dotnet.framework)

Quantcast