首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Windows Mobile >

如何判断当前的连接是CMWAP 还是CMNET?

2012-03-03 
怎么判断当前的连接是CMWAP 还是CMNET??如题:[解决办法]直接给你代码得了。C/C++ codeHRESULT GetAPNFromEn

怎么判断当前的连接是CMWAP 还是CMNET??
如题:

[解决办法]
直接给你代码得了。

C/C++ code
HRESULT GetAPNFromEntryName(LPCTSTR szEntryName, LPTSTR szAPN, int cchAPN){    // parm query formating string of "CM_GPRSEntries Configuration Service Provider"    LPCTSTR szFormat =    TEXT("<wap-provisioningdoc>")        TEXT("    <characteristic type=\"CM_GPRSEntries\">")        TEXT("        <characteristic type=\"%s\">")        TEXT("            <characteristic type=\"DevSpecificCellular\">")        TEXT("                <parm-query name=\"GPRSInfoAccessPointName\"/>")        TEXT("            </characteristic>")        TEXT("        </characteristic>")        TEXT("    </characteristic>")        TEXT("</wap-provisioningdoc>");    HRESULT hr = E_FAIL;    LPTSTR szOutput   = NULL;    if(NULL == szEntryName)        return E_INVALIDARG;    // prepare the query string with the special entry name    LPTSTR szInput = new TCHAR[_tcslen(szFormat) + _tcslen(szEntryName) + 10];    if(NULL == hr)        return E_OUTOFMEMORY;    _stprintf(szInput, szFormat, szEntryName);    // Process the XML.    hr = DMProcessConfigXML(szInput, CFGFLAG_PROCESS, &szOutput);    if(S_OK == hr)    {        hr = E_FAIL;        // find the value of GPRSInfoAccessPointName param        LPTSTR szAPNStrStart = _tcsstr(szOutput, TEXT("value=\""));        if(NULL != szAPNStrStart)        {            szAPNStrStart += _tcslen(TEXT("value=\""));            // find the end of value string            LPTSTR szAPNStrEnd = _tcsstr(szAPNStrStart, TEXT("\""));            if(NULL != szAPNStrEnd)            {                // set the null char at the end of the value string                *szAPNStrEnd = TEXT('\0');                // get the final Access Point Name string                _tcsncpy(szAPN, szAPNStrStart, cchAPN);                hr = S_OK;            }        }    }    // the caller must delete the XML returned from DMProcessConfigXML.    delete[] szOutput;    // clear the input string    delete[] szInput;    return hr;}void fun(){        char m_sNowTraffic[255];    DWORD dwSize = 0;    HRESULT hr = E_FAIL;    //    // Get the the required size of the buffer     // with which the function needs to be called on the next attempt.    //    hr = ConnMgrQueryDetailedStatus(NULL, &dwSize);    if(STRSAFE_E_INSUFFICIENT_BUFFER != hr)        return hr;    LPBYTE pBuffer = new BYTE[dwSize];    if(NULL == pBuffer)        return E_OUTOFMEMORY;    //    // Get the connection information    //    hr = ConnMgrQueryDetailedStatus((CONNMGR_CONNECTION_DETAILED_STATUS*)pBuffer, &dwSize);    if(S_OK == hr)    {        //        // Enum each connection entry        //        CONNMGR_CONNECTION_DETAILED_STATUS* cmStatus  = (CONNMGR_CONNECTION_DETAILED_STATUS*)pBuffer;        while(NULL != cmStatus)        {            // find the connected GPRS entry            if((cmStatus->dwParams & (CONNMGRDETAILEDSTATUS_PARAM_TYPE | CONNMGRDETAILEDSTATUS_PARAM_DESCRIPTION | CONNMGRDETAILEDSTATUS_PARAM_CONNSTATUS)) &&                CM_CONNTYPE_CELLULAR == cmStatus->dwType &&                CONNMGR_STATUS_CONNECTED == cmStatus->dwConnectionStatus &&                NULL != cmStatus->szDescription)                    {                // get the connected GPRS APN                if(S_OK == GetAPNFromEntryName(cmStatus->szDescription, (LPTSTR)szAPN, 200))                    MessageBox((LPTSTR)szAPN, cmStatus->szDescription,MB_OK | MB_ICONINFORMATION);            }            // test the next one            cmStatus = cmStatus->pNext;        }    }    // clear the buffer    delete pBuffer;}
------解决方案--------------------


ConnMgrEnumDestinations 枚举 guid 与 { 0x436ef144, 0xb4fb, 0x4863, { 0xa0, 0x41, 0x8f, 0x90, 0x5a, 0x62, 0xc5, 0x72 } };

 
 { 0x7022e968, 0x5a97, 0x4051, { 0xbc, 0x1c, 0xc5, 0x78, 0xe2, 0xfb, 0xa5, 0xd9 } };分别对比就可以了
[解决办法]

探讨
为啥要区分CMWAP 和CMNET呢,能连上网传数据不就行了么?

热点排行