能力值:
( LV2,RANK:10 )
|
-
-
2 楼
看样子是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);
|
能力值:
( LV7,RANK:110 )
|
-
-
3 楼
谢谢!我就是想要这个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;
}
|
|
|