春暖花开
雪化了,花开了,春天来了
posts - 149,comments - 125,trackbacks - 0

摘自:http://www.cnblogs.com/biosli/articles/1414259.html


Windows Mobile,DMProcessConfigXML 使用实例

最近遇到了创建连接点的问题(飞信就能自己创建来着),到网上搜罗了一下解决方法。这里总结一下:

这些方法主要是针对函数DMProcessConfigXML里面的第一个参数来的,函数的具体使用方法参见MSDN

MSDN没有对第一个参数做太多解释,下面提供一些使用实例:


LPCWSTR strFavoriteXml =         
L
"<wap-provisioningdoc>"
  L
"<characteristic type=\"CM_GPRSEntries\">"
    L
"<characteristic type=\"Internet Connect\">"
      L
"<parm name=\"DestId\" value=\"{436EF144-B4FB-4863-A041-8F905A62C572}\" />"
      L
"<characteristic type=\"DevSpecificCellular\">"
        L
"<parm name=\"GPRSInfoAccessPointName\" value=\"cmnet\" />"
      L
"</characteristic>"
    L
"</characteristic>"
  L
"</characteristic>"
L
"</wap-provisioningdoc>"//DestID是自己定义的GUID,当然,也有已经定义好的GUID可以直接用         

LPWSTR pszwXMLout 
= NULL;
HRESULT hr 
= DMProcessConfigXML(strFavoriteXml, CFGFLAG_PROCESS, &pszwXMLout);
if ( pszwXMLout )
{
     delete [] pszwXMLout;
     pszwXMLout 
= NULL;

 


CString strFavoriteXml = 
L
"<wap-provisioningdoc>" 
  L
"<characteristic type=\"CM_Networks\">"
    L
"<characteristic type=\"Test_GPRS\">"
      L
"<parm name=\"DestId\" value=\"{D1D06580-C364-55ec-9421-6ACF34129C58}\" />"
    L
"</characteristic>"
  L
"</characteristic>"
  L
"<characteristic type=\"CM_GPRSEntries\">"
    L
"<characteristic type=\"Test_GPRS\">"
      L
"<parm name=\"DestId\" value=\"{D1D06580-C364-55ec-9421-6ACF34129C58}\" />"
      L
"<characteristic type=\"DevSpecificCellular\">"
        L
"<parm name=\"BearerInfoValid\" value=\"1\" />"
        L
"<parm name=\"GPRSInfoValid\" value=\"1\" />"
        L
"<parm name=\"GPRSInfoProtocolType\" value=\"2\" />"
        L
"<parm name=\"GPRSInfoL2ProtocolType\" value=\"PPP\" />"
        L
"<parm name=\"GPRSInfoAccessPointName\" value=\"cmwap\" />"
        L
"<parm name=\"GPRSInfoAddress\" value=\"\" />"
        L
"<parm name=\"GPRSInfoDataCompression\" value=\"1\" />"
        L
"<parm name=\"GPRSInfoHeaderCompression\" value=\"1\" />"
        L
"<parm name=\"GPRSInfoParameters\" value=\"\" />"
      L
"</characteristic>"
    L
"</characteristic>"
  L
"</characteristic>"
  L
"<characteristic type=\"CM_ProxyEntries\">"
    L
"<characteristic type=\"WAP\">"
      L
"<parm name=\"SrcId\" value=\"{D1D06580-C364-55ec-9421-6ACF34129C58}\" />"
      L
"<parm name=\"DestId\" value=\"{436EF144-B4FB-4863-A041-8F905A62C572}\" />"
      L
"<parm name=\"Proxy\" value=\"10.0.0.172:80\" />"
      L
"<parm name=\"Enable\" value=\"1\" />"
      L
"<parm name=\"Type\" value=\"1\" />"
    L
"</characteristic>"
  L
"</characteristic>"
L
"</wap-provisioningdoc>";

LPWSTR pszwXMLout 
= NULL;
HRESULT hr 
= DMProcessConfigXML(strFavoriteXml, CFGFLAG_PROCESS, &pszwXMLout);

if ( pszwXMLout )
{
  delete [] pszwXMLout;
  pszwXMLout 
= NULL;
}

 


LPCTSTR szFormat =
L
"<wap-provisioningdoc>"
  L
"<characteristic type=\"CM_GPRSEntries\">"
    L
"<characteristic type=\"%s\">"
      L
"<characteristic type=\"DevSpecificCellular\">"
        L
"<parm-query name=\"GPRSInfoAccessPointName\"/>"
      L
"</characteristic>"
    L
"</characteristic>"
  L
"</characteristic>"
L
"</wap-provisioningdoc>"
//%s为 "移动梦网(GPRS)" "GPRS连接互联网" 等,
//可以用ConnMgrQueryDetailedStatus枚举,CONNMGR_CONNECTION_DETAILED_STATUS的szDescription

 


LPCTSTR szFormat = 
L
"<wap-provisioningdoc>"
  L
"<characteristic type="UnInstall">"
    L
"<characteristic type="[AppName]">"
      L
"<parm name="uninstall" value="1"/>"
    L
"</characteristic>"
  L
"</characteristic>"
L
"</wap-provisioningdoc>"
//[AppName] = 注册表中对应的该软件的名称 一般是:生成cab包使用的inf中的provider和appname的组合
//如:provider = aaa appname = bbb <characteristic type="aaa bbb"> 然后用DMProcessConfigXML来处理

 

关闭硬件按钮声音

 


LPCWSTR strFavoriteXml =
L
"<wap-provisioningdoc>"
  L
"<characteristic type="EMAIL2">"
    L
"<characteristic type="[GUID]">"
      L
"<parm name="SERVICENAME" value="[MailServiceName]"/>"
      L
"<parm name="SERVICETYPE" value="POP3"/>"
      L
"<parm name="INSERVER" value="[popserver]"/>"
      L
"<parm name="OUTSERVER" value="[smtpserver]"/>"
      L
"<parm name="AUTHNAME" value="[alias]"/>"
      L
"<parm name="AUTHSECRET" value="[password]"/>"
      L
"<parm name="DOMAIN" value="[domain]"/>"
      L
"<parm name="REPLYADDR" value="[emailAddress]"/>"
    L
"</characteristic>"
  L
"</characteristic>"
L
"</wap-provisioningdoc>"
//[]中的参数都是自定义的

 


//This XML will add or overwrite a Wi-Fi access point connection with SSID COWO, no encryption, open authentication. 
//This connection is regarded as an internet connection. 

LPCWSTR 
in = \
L
"<wap-provisioningdoc>"
L
" <characteristic type=\"Wi-Fi\""
L
"  <characteristic type=\"access-point\""
L
"   <characteristic type=\"COWO\""
L
"     <parm name=\"DestId\" value=\"{436EF144-B4FB-4863-A041-8F905A62C572}\"/>"
L
"     <parm name=\"AdHoc\" value=\"0\"/>"
L
"     <parm name=\"Authentication\" value=\"0\"/>"
L
"     <parm name=\"Encryption\" value=\"1\"/>"
L
"     <parm name=\"KeyProvided\" value=\"0\"/>"
L
"     <parm name=\"NetworkKey\" value=\"\"/>"
L
"     <parm name=\"KeyIndex\" value=\"1\"/>"
L
"     <parm name=\"Use8021x\" value=\"0\"/>"
L
"     <parm name=\"EAPType\" value=\"25\"/>"
L
"   </characteristic>"
L
"  </characteristic>"
L
" </characteristic>"
L
"</wap-provisioningdoc>";

 


//There are some M$ examples about recursive query of all WiFi connections. 
//Here's an example on how to query a specific connection. 

LPCWSTR 
in = 
L
"<wap-provisioningdoc>"
L
" <characteristic type=\"Wi-Fi\""
L
"  <characteristic type=\"access-point\""
L
"   <characteristic-query type=\"COWO\" /> "
L
"  </characteristic>"
L
" </characteristic>"
L
"</wap-provisioningdoc>";

 

参考连接:

http://blog.csdn.net/caicaileowince/archive/2008/07/01/2601456.aspx

http://cowo.supersized.org/archives/14-Example-usage-of-DMProcessConfigXML-on-WinCE-5.0.html

来自小李匪盗的连接:

http://blog.csdn.net/pknife/archive/2008/05/21/2467602.aspx

http://blog.csdn.net/pknife/archive/2008/05/22/2469126.aspx

http://blog.csdn.net/pknife/archive/2008/11/07/3248315.aspx

posted on 2009-04-21 16:50 Sandy 阅读(1170) 评论(0)  编辑 收藏 引用 所属分类: Window Mobile

只有注册用户登录后才能发表评论。
【推荐】超50万行VC++源码: 大型组态工控、电力仿真CAD与GIS源码库
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理