GetAdaptersInfo / WSAIoctl の SIO_GET_INTERFACE_LIST / WMI の Win32_NetworkAdapterConfiguration でオフラインのIPアドレスの設定情報が取得できない件
if (GetAdaptersInfo(pAdapterInfo, &ulOutBufLen) == NO_ERROR) { pAdapter = pAdapterInfo; while (pAdapter) { printf("IP: %s",pAdapter->IpAddressList.IpAddress.String); printf("MASK: %s",pAdapter->IpAddressList.IpMask.String); printf("DefGW: %s",pAdapter->GatewayList.IpAddress.String); pAdapter = pAdapter->Next; } } |
SOCKET sd = WSASocket(AF_INET, SOCK_DGRAM, 0, 0, 0, 0); INTERFACE_INFO if_list[20]; unsigned long ret_bytes; int n,num_if; if (sd != SOCKET_ERROR) { if (WSAIoctl(sd, SIO_GET_INTERFACE_LIST, NULL, 0, &if_list, sizeof(if_list), &ret_bytes, NULL, NULL) != SOCKET_ERROR) { num_if = ret_bytes / sizeof(INTERFACE_INFO); for (n = 0; n < num_if; ++n) { |
if((hRes = m_pIWbemServices->ExecQuery(SysAllocString(L"WQL"),SysAllocString(L"select * from Win32_NetworkAdapterConfiguration"), WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, NULL,&pEnumBIOS)) == S_OK) { while(((hRes = pEnum->Next(TIMEOUT, 1, &pB, &uReturned)) == S_OK) && (uReturned == 1)) { char ip[32],ip2[32],ip3[32],mac[64],ifn[128]; int ui; *mac=*ip=*ip2=*ip3=*ifn=0; VariantInit(&pVal); pB->Get(L"Description", 0, &pVal, NULL, NULL); if(pVal.vt==VT_BSTR)wsprintf(ifn,"%ws",pVal.bstrVal); VariantInit(&pVal); VariantInit(&pVal); |
Comments