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.