首页
论坛
课程
招聘
[求助](又遇到抽筋的问题了)……不知道怎样得到当前活动GPRS的APN名……
2009-5-19 19:40 4468

[求助](又遇到抽筋的问题了)……不知道怎样得到当前活动GPRS的APN名……

2009-5-19 19:40
4468


找了好多地方都没有能成功的代码……重要的是具体API目前不知道……好像是ConnMgrQueryDetailedStatus但是没一次用成功。

[培训] 优秀毕业生寄语:恭喜id咸鱼炒白菜拿到远超3W月薪的offer,《安卓高级研修班》火热招生!!!

收藏
点赞0
打赏
分享
最新回复 (2)
雪    币: 268
活跃值: 活跃值 (19)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
CodeBreaker 活跃值 2009-5-20 09:10
2
0
看样子是Windows Mobile平台,  没错,正是ConnMgrQueryDetailedStatus这个API

HRESULT WINAPI ConnMgrQueryDetailedStatus(
  CONNMGR_CONNECTION_DETAILED_STATUS *pStatusBuffer,
  DWORD *pcbBufferSize
);

typedef struct _CONNMGR_CONNECTION_DETAILED_STATUS{

  struct _CONNMGR_CONNECTION_DETAILED_STATUS* pNext;

  DWORD dwVer;

  DWORD dwParams;

  DWORD dwType;

  DWORD dwSubtype;

  DWORD dwFlags;

  DWORD dwSecure;

  GUID guidDestNet;

  GUID guidSourceNet;

  TCHAR* szDescription;

  TCHAR* szAdapterName;

  DWORD dwConnectionStatus;

  SYSTEMTIME LastConnectTime;

  DWORD dwSignalQuality;

  CONNMGR_CONNECTION_IPADDR* pIPAddr;

} CONNMGR_CONNECTION_DETAILED_STATUS;

szDescription  就是APN Name

示范代码

HRESULT hres;

DWORD dwSize = 0;

OLECHAR ochguid[256] = {0};
 

ConnMgrQueryDetailedStatus(NULL, &dwSize);

CONNMGR_CONNECTION_DETAILED_STATUS *pstatus = (CONNMGR_CONNECTION_DETAILED_STATUS*) malloc(dwSize);

 

hres = ConnMgrQueryDetailedStatus(pstatus, &dwSize);
 

while(pstatus != NULL)

{

// lastly connected & connected & has ip address

if( pstatus->dwConnectionStatus & CONNMGR_STATUS_CONNECTED && pstatus->dwParams & CONNMGRDETAILEDSTATUS_PARAM_LASTCONNECT && pstatus->dwParams & CONNMGRDETAILEDSTATUS_PARAM_IPADDR)

{

StringFromGUID2(pstatus->guidDestNet, ochguid, 256);

if( pstatus->pIPAddr != NULL )

{

      for( int i=0; i<pstatus->pIPAddr->cIPAddr; i++)

     {

         // Is this is what you need !!!

        // here is the three parameters from your question

        in_addr inaddress = *(in_addr*)&((sockaddr*)&pstatus->pIPAddr->IPAddr[i])->sa_data[2];

        printf("IP Address : %s \n", inet_ntoa(inaddress));

        wprintf(L"Destination GUID : %s \n", ochguid);

        if( pstatus->szAdapterName != NULL )

            wprintf(L"Adapter Name : %s \n", pstatus->szAdapterName);

        if( pstatus->szDescription != NULL )

            wprintf(L"Description : %s \n", pstatus->szDescription);

    }
}

}

pstatus = pstatus->pNext;

}

 

free(pstatus);

雪    币: 115
活跃值: 活跃值 (10)
能力值: ( LV7,RANK:110 )
在线值:
发帖
回帖
粉丝
NETTF小金 活跃值 2 2009-5-20 11:26
3
0
谢谢!我就是想要这个StringFromGUID2(pstatus->guidDestNet, ochguid, 256);

搞定了,十分感谢楼上的朋友

        LPTSTR GetActiveAPN(){
                //cmwap={79B360D3-C015-442C-898C-F432CF456BD7}
                //cmnet={ADB0B001-10B5-3F39-27C6-9742E785FCD4}
                //
                LPTSTR lpszTmp=L"";
                wsprintf(lpszTmp,L"%s",gNetGuid);
                if(!_tcscmp(lpszTmp,L"{79B360D3-C015-442C-898C-F432CF456BD7}")){
                        lpszTmp=L"CMWAP";
                }else if(!_tcscmp(lpszTmp,L"{ADB0B001-10B5-3F39-27C6-9742E785FCD4}")){
                        lpszTmp=L"CMNET";
                }else{
                        lpszTmp=L"(未知)";
                }
                return lpszTmp;
        }

游客
登录 | 注册 方可回帖
返回