[Reprinted] distinguish cmwap or cmnet access points in Windows Mobile

Source: Internet
Author: User

In my previous article, I talked about the use of network access points.

However, I always feel that something is wrong and I am not clear about it. I carefully studied it and made some new gains.

We once thought that the connmgrenumdestinations function obtained is a network access point. Yes, you can say so now, but it is not accurate. Like references in C ++, I think it is an alias. See the name obtained by using this function: Internet Settings, WAP, WAP network, secure WAP network, unit settings, default Internet Settings, and default unit settings. For GPRS, apart from self-built access points, we usually use Internet Settings and WAP, which can be considered as cmnet and cmwap access points, and the machine is ready for factory settings.

The parameters used by the connmgrenumdestinations function are defined as follows:
Typedef struct _ connmgr_destination_info
{
Guid; // @ field guid associated with network
Tchar szdescription [connmgr_max_desc]; // @ field description of Network
Bool fsecure; // @ field is it OK to allow multi-homing on the network
} Connmgr_destination_info;

Obviously, neither the cmwap or cmnet mark nor the proxy server information is obtained here. The legendary connmgrprovidermessage does not seem to work. Is it confusing to obtain more information by querying the registry? Unwilling.

The focus is coming soon.

Use the connmgrquerydetailedstatus function. The usage is as follows:
DWORD dwsize = 0;
Hresult hR = e_fail;

HR = connmgrquerydetailedstatus (null, & dwsize );
If (strsafe_e_insufficient_buffer! = HR)
{
Return hr;
}

Lpbyte pbuffer = new byte [dwsize];
If (null = pbuffer)
{
Return e_outofmemory;
}

HR = connmgrquerydetailedstatus (connmgr_connection_detailed_status *) pbuffer, & dwsize );
If (s_ OK = HR)
{
Connmgr_connection_detailed_status * cmstatus = (connmgr_connection_detailed_status *) pbuffer;
While (null! = Cmstatus)
{
If (cm_conntype_cellular = cmstatus-> dwtype) // indicates a GPRS connection.
{
// Coganhaja
}

Cmstatus = cmstatus-> pnext;
}
}

Delete [] pbuffer;

Note that cmstatus-> dwtype is cm_conntype_cellular, which indicates a GPRS connection. As shown above, through cmstatus-> szdescription, we can obtain information such as GPRS connection to the Internet, dial-up connection to the Internet, and mobile Dream network (GPRS) or a strange name like null-Corp-{18ad9fbd-f716-acb6-fd8a-1965db95b814.

See the definition of connmgr_connection_detailed_status:
Typedef struct _ connmgr_connection_detailed_status
{
Struct _ connmgr_connection_detailed_status * pnext;

DWORD dwver; // @ field structure version; current is connmgrdetailedstatus_version.
DWORD dwparams; // @ field combination of connmgrdetailedstatus_param _ * values.

DWORD dwtype; // @ field one of cm_conntype _ * values.
DWORD dwsubtype; // @ field one of cm_connsubtype _ * values.

DWORD dwflags; // @ field combination of cm_dsf _ * flags.
DWORD dwsecure; // @ field secure level (0 = Not-secure) of connection.

Guid guiddestnet; // @ field guid of destination network.
Guid guidsourcenet; // @ field guid of source network.

Tchar * szdescription; // @ field name of connection, 0-terminated string or null if n/.
Tchar * szadaptername; // @ field name of adapter, 0-terminated or null if n/.

DWORD dwconnectionstatus; // @ field one of connmgr_status _*.
Systemtime lastconnecttime; // @ field time connection was last established.
DWORD dwsignalquality; // @ field signal quality normalized in the range 0-255.

Connmgr_connection_ipaddr * pipaddr; // @ field available IP addrs, or null if n/.
// End of version 1 fields.

} Connmgr_connection_detailed_status;

A bunch of black parameters, so scary. Fortunately, we only need to use szdescription and guiddestnet. Guiddestnet can be used for connmgrestablishconnectionsync. The usefulness of szdescription is explained later.

Can anyone see this? It's almost time to reach the other side of victory.

In the end, we still need to use the dmprocessconfigxml function. (How is this function omnipotent ?)

Obtain the APN of the Access Point as follows:
Tchar * szxmlin =
L "<WAP-provisioningdoc>"
L "<characteristic type =/" cm_uplsentries/">"
L "<characteristic type =/" GPRS connected to the internet/">"
L "<characteristic type =/" devspecificcellular/">"
L "<parm-query name =/" maid/"/>"
L "</characteristic>"
L "</characteristic>"
L "</characteristic>"
L "</WAP-provisioningdoc> ";

Lpwstr pszwxmlout = NULL;
Hresult hR = dmprocessconfigxml (szxmlin, export flag_process, & pszwxmlout );
// Process pszwxmlout
If (pszwxmlout)
{
Delete [] pszwxmlout;
Pszwxmlout = NULL;
}

The above GPRS connection to the Internet corresponds to the previously obtained szdescription.

If everything goes well, the returned pszwxmlout should be as follows:
<WAP-provisioningdoc> <characteristic type = "cm_uplsentries"> <characteristic type = "GPRS connected to the Internet"> <characteristic type = "devspecificcellular"> <parm name = "regular"

Value = "cmnet"/> </characteristic> </WAP-provisioningdoc>

Yes, the APN is included in the value, which is indeed cmnet.

Try to change to mobile Dream network (GPRS). We can get the APN as cmwap.

Note: If you use the szdescription obtained by connmgrenumdestinations, you cannot obtain the correct APN information.

To obtain the proxy server information, szxmlin is as follows:
Tchar * szxmlin =
L "<WAP-provisioningdoc>"
L "<characteristic type =/" cm_proxyentries/">"
L "<characteristic type =/" WAP/">"
L "<parm-query name =/" Proxy/"/>"
L "</characteristic>"
L "</characteristic>"
L "</WAP-provisioningdoc> ";

The name here does not match the name obtained by connmgrquerydetailedstatus. I do not know how to explain it. If you are interested, you can open the registry and Check HKEY_LOCAL_MACHINE/comm/connmgr. Fortunately, we know that for cmwap, the mobile proxy server is 10.0.0.172.

For more information about cm_networks, cm_gprs sentries, cm_proxyentries, and the XML format related to this, see msdn:
(English version) ms-help: // Ms. msdnqtr. v80.en/ms. msdn. v80/ms. mobembdev. v10.en/guide_ppc/html/ppc_wcconconfiguringconnectionmanagerforpocketpcozup.htm
(Chinese version) ms-help: // Ms. msdnqtr. v80.chs/ms. msdn. v80/ms. mobembdev. v10.en/guide_ppc/html/ppc_wcconconfiguringconnectionmanagerforpocketpcozup.htm

This article from the csdn blog, source: http://blog.csdn.net/pknife/archive/2008/11/07/3248315.aspx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.