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
---------------------------------------------------------------------------------------------------------------------
创建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;
}
----------------------------------------------------------------------------------------------------
创建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;
}
----------------------------------------------------------------------------------------------
卸载应用程序
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来处理
-------------------------------------------------------------------------------------
关闭硬件按钮声音
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配置数据。
---------------------------------------------------------------------------------------------------
创建一封新的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>"
//[]中的参数都是自定义的
------------------------------------------------------------------------------------------------------------
创建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>";
-------------------------------------------------------------------------------------------------------
枚举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>";