开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜