[WM] How to Find the network in use in PPC (source code)

Source: Internet
Author: User

This article is transferred from:Blog flying togetherFor the original article, see here:Http://17feixiang.com/article/jishu/83.htm

 

This article describes how to determine whether a PPC network is connected or disconnected.ArticleDescribes how to enumerate the current network status and find the network in use. A simple application is to determine whether it is a free network or a paid network after receiving a notification that the system is connected to the network. Generally, the free network is WiFi and ActiveSync, And the paid network is cmnet and cmwap. The followingCodeTo determine what network the current connected network is, you need to use the connmgrquerydetailedstatus function to obtain the network details, the network type can be obtained from its dwtype. dwsubtype can know the specific network type. The specific code is as follows, which is already detailed. If you have any questions, you can leave a message on 17feixiang.com. 

 

Code

Connmgr_connection_detailed_status * Statusbuffer;
Connmgr_connection_detailed_status * Statusbuffertemp;
DWORD invalid buffersize =   0 ;

Connmgrquerydetailedstatus (null,&Optional buffersize );
Statusbuffer=(Connmgr_connection_detailed_status*)NewByte [bytes buffersize];
Connmgrquerydetailedstatus (statusbuffer,&Optional buffersize );
Statusbuffertemp=Statusbuffer;

While (Statusbuffertemp ! = Null)
{
If (Statusbuffertemp - > Dwconnectionstatus = Connmgr_status_connected)
{
If (Statusbuffertemp - > Dwtype = Cm_conntype_nic)
{
Switch (Statusbuffertemp - > Dwsubtype)
{
Case Cm_connsubtype_nic_wifi:
MessageBox (_ T ( " WiFi " ));
Break ;

CaseCm_connsubtype_nic_ethernet:
Break;
}
}

If (Statusbuffertemp - > Dwtype = Cm_conntype_cellular)
{
Switch (Statusbuffertemp - > Dwsubtype)
{
Case Cm_connsubtype_cellular_csd:
Break ;

CaseCm_connsubtype_cellular_gprs:
MessageBox (_ T ("GPRS"));
Break;

case cm_connsubtype_cellular_1xrtt:
MessageBox (_ T ( " 1 xrtt " ));
Break ;

case cm_connsubtype_cellular_1xevdo:
MessageBox (_ T ( " 1 xevdo " ));
Break ;

case cm_connsubtype_cellular_1xevdv:
Break ;

case cm_connsubtype_cellular_edge:
MessageBox (_ T ( " edge " ));
Break ;

case cm_connsubtype_cellular_umts:
Break ;

case cm_connsubtype_cellular_voice:
MessageBox (_ T ( " voice " ));
Break ;

case cm_connsubtype_cellular_ptt:
Break ;

//Case cm_connsubtype_cellular_hsdpa:
//Break;
}
}

If (Statusbuffertemp - > Dwtype = Cm_conntype_proxy)
{
Switch (Statusbuffertemp - > Dwsubtype)
{
Case Cm_connsubtype_proxy_wap:
MessageBox (_ T ( " WAP " ));
Break ;

CaseCm_connsubtype_proxy_http:
MessageBox (_ T ("HTTP"));
Break;
}
}

If (Statusbuffertemp - > Dwtype = Cm_conntype_pc)
{
Switch (Statusbuffertemp - > Dwsubtype)
{
Case Cm_connsubtype_pc_desktoppassthrough:
MessageBox (_ T ( " ActiveSync " ));
Break ;

CaseCm_connsubtype_pc_unknown:
Break;
}
}

}
Statusbuffertemp=Statusbuffertemp-> Pnext;
}

Delete statusbuffer;

 

PS:

Unfortunately, this API is not available in msdn. You need to check the header file # include <connmgr_status.h> and Windows Mobile document.

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.