Windows Mobile,DMProcessConfigXML 使用執行個體

來源:互聯網
上載者:User

這些方法主要是針對函數DMProcessConfigXML裡面的第一個參數來的,函數的具體使用方法參見MSDN。

MSDN沒有對第一個參數做太多解釋,下面提供一些使用執行個體:

1,    建立cmnet串連

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;
}

--------------------------------------------------------------------------------
2,建立CMWAP串連

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;
}

--------------------------------------------------------------------------------

3,卸載應用程式

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來處理

--------------------------------------------------------------------------------

4,關閉硬體按鈕鈴聲

LPCTSTR szFormat =
L"<wap-provisioningdoc>"
L"<characteristic type="Sounds">"
    L"<characteristic type="ControlPanel\Sounds\KeyPress">"
      L"<parm name="Mode" value="1"/> <!-- 0=none, 1=tone, 2=click -->"
    L"</characteristic>"
L"</characteristic>"
L"</wap-provisioningdoc>"
//使用DMProcessConfigXML()函數通過組態管理員發送上面的XML配置資料。

--------------------------------------------------------------------------------

5,建立一封新的Email

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>"
//[]中的參數都是自訂的

--------------------------------------------------------------------------------

6, 建立Wi-Fi串連

//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>";

--------------------------------------------------------------------------------

7,枚舉Wi-Fi連接點

//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>";

--------------------------------------------------------------------------------

3,擷取某個串連的存取點

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

from: http://blog.csdn.net/lianghuating/archive/2009/03/25/4022486.aspx

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.