Viv Coco
Viv Coco

Reputation: 21

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

Upvotes: 1

Views: 1944

Answers (2)

Trevor Balcom
Trevor Balcom

Reputation: 3898

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;
}

Upvotes: 1

ctacke
ctacke

Reputation: 67188

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.

Upvotes: 0

Related Questions