• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            Benjamin

            靜以修身,儉以養(yǎng)德,非澹薄無以明志,非寧靜無以致遠。
            隨筆 - 397, 文章 - 0, 評論 - 196, 引用 - 0
            數(shù)據(jù)加載中……

            如何判斷GPRS的接入點

            思路:用ConnMgrQueryDetailedStatus找到Dest GUID, 然后根據(jù)Dest GUID用DMProcessConfigXML函數(shù)透過CM_GPRSEntries Configuration Service Provider來查接入點名稱。
            示例代碼:


            #include <stdlib.h>
            #include <windows.h>

            #include <connmgr.h>
            #include <Connmgr_status.h>
            #include <Cfgmgrapi.h>
            #include <strsafe.h>

            //
            //   FUNCTION: GetAPNFromEntryName(LPCTSTR szEntryName, LPTSTR szAPN, int cchAPN)
            //
            //   PURPOSE: Get the GPRS Access Point Name form the Entry Name
            //
            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;
            }


            //
            // we will enum the all connected GPRS
            // and display their entry name and APN on the message box
            //
            int WINAPI WinMain(HINSTANCE hInstance,
                               HINSTANCE hPrevInstance,
                               LPTSTR    lpCmdLine,
                               int       nCmdShow)
            {
                TCHAR szAPN[200];

                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, szAPN, 200))
                                MessageBox(NULL, szAPN, cmStatus->szDescription, MB_OK | MB_ICONINFORMATION);

                        }

                        // test the next one
                        cmStatus = cmStatus->pNext;
                    }
                }


                // clear the buffer
                delete pBuffer;


                return 0;
            }

            posted on 2009-02-09 17:09 Benjamin 閱讀(1772) 評論(3)  編輯 收藏 引用 所屬分類: PDA/PPC開發(fā)

            評論

            # re: 如何判斷GPRS的接入點  回復(fù)  更多評論   


            Cannot open include file: 'Connmgr_status.h': No such file or directory

            樓主,這個問題問題怎么解決?。?
            2009-07-14 10:06 | beautymind

            # re: 如何判斷GPRS的接入點  回復(fù)  更多評論   

            用了樓主的方法,想判斷 CDMA 手機是用了 CTWAP 還是 CTNET 網(wǎng)絡(luò),能得到網(wǎng)絡(luò)的描述名稱,但是當(dāng)我進一步想拿到 APN 值時,返回的 XML 字符串是類似以下的內(nèi)容:
            ----------------
            <wap-provisioningdoc>

            <characteristic type="CM_GPRSEntries">
            <characteristic-error type="ctwap">
            <characteristic type="DevSpecificCellular">

            <parm-query name="GPRSInfoAccessPointName"/>

            </characteristic>

            </characteristic-error>
            </characteristic></wap-provisioningdoc>
            -------------------
            這是什么原因呢?
            2010-04-03 15:45 | Water Lin

            # re: 如何判斷GPRS的接入點  回復(fù)  更多評論   

            GPRS和CDMA是兩種不同的網(wǎng)絡(luò),而且CDMA的芯片是美國高通所擁有,所以不是這么判斷的。一般在C網(wǎng)下不用判斷的,都是CMWAP。
            2010-04-04 08:00 | Benjamin
            区久久AAA片69亚洲| 99精品久久精品一区二区| 久久91精品综合国产首页| 91精品婷婷国产综合久久| a级毛片无码兔费真人久久| 欧美色综合久久久久久| 色88久久久久高潮综合影院| 国产亚洲欧美成人久久片 | 久久香蕉国产线看观看猫咪?v| 久久久免费观成人影院| 看久久久久久a级毛片| 国产一区二区精品久久岳| 久久久久久综合网天天| 精品久久久久国产免费| 久久久久波多野结衣高潮| 久久99精品久久久久久噜噜| 久久亚洲精精品中文字幕| 免费一级欧美大片久久网 | 久久亚洲私人国产精品vA| 精品99久久aaa一级毛片| 久久久久亚洲AV无码专区体验 | 伊人久久亚洲综合影院| 久久久久国产一级毛片高清版| 日韩十八禁一区二区久久| 久久狠狠色狠狠色综合| 久久久久亚洲AV成人片| 亚洲欧洲日产国码无码久久99| 四虎影视久久久免费| 久久人人爽人人爽AV片| 精品久久久久久99人妻| 亚洲天堂久久精品| 香蕉久久一区二区不卡无毒影院 | 亚洲一区中文字幕久久| 91视频国产91久久久| 久久久久久亚洲Av无码精品专口| 国产69精品久久久久观看软件 | 久久久久99精品成人片直播| 成人午夜精品无码区久久| 亚洲精品乱码久久久久久| 色欲久久久天天天综合网精品| 伊人久久大香线蕉av一区|