简体   繁体   中英

Check if there is a TCP/IP connection and if it's WiFi or 3G - Windows Mobile 6.5 - C/C++

I need in my Windows Mobile 6.5 C/C++ application to detect if there is a TCP/IP connection and if yes, then to detect if it's WiFi or 3G. How could I do that? I found some C# samples, but nothing for C/C++.

Any tip would be appreciated.

TIA, MeCoco

This is possible using the Connection Manager API. The name of the function is ConnMgrQueryDetailedStatus . The CONNMGR_CONNECTION_DETAILED_STATUS structure fields you are interested in are: dwParams, dwType, and dwSubtype.

// TODO: Fill in the structure using ConnMgrQueryDetailedStatus in a loop until it succeeds.

// Check to see if there is an active Wi-Fi connection currently available to ConnMgr.
BOOL IsWiFiAvailable(CONNMGR_CONNECTION_DETAILED_STATUS* ccds)
{
     return ccds->dwParams & CONNMGRDETAILEDSTATUS_PARAM_SUBTYPE && 
            ccds->dwParams & CONNMGRDETAILEDSTATUS_PARAM_TYPE &&
            ccds->dwType == CM_CONNTYPE_NIC &&
            ccds->dwSubtype == CM_CONNSUBTYPE_NIC_WIFI;
}


// Check to see if there is an active Wi-Fi connection currently available to ConnMgr.
BOOL Is3GAvailable(CONNMGR_CONNECTION_DETAILED_STATUS* ccds)
{
     // This will return FALSE if you have non 3G GPRS connection available.
     return ccds->dwParams & CONNMGRDETAILEDSTATUS_PARAM_SUBTYPE && 
            ccds->dwParams & CONNMGRDETAILEDSTATUS_PARAM_TYPE &&
            ccds->dwType == CM_CONNTYPE_CELLULAR_GPRS &&
            ccds->dwSubtype == CM_CONNSUBTYPE_CELLULAR_UMTS;
}

I've not actually done this before, so this answer is going to be an educated guess.

My guess is that first you'd see if you have any connection at all by trying to ping or resolve some known-good remote address. If that works, you'd check with the Connection Manager APIs to find out what connection is being used for the communication.

At that point you probably won't know if it's WiFi or 3G. You might be able to use ossvcs.dll to deduce which it is based on the radio type though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM