多网卡多IP信息

 

  1. void CViewAdapterInfoDlg::GetInfo()
  2. {
  3.     if (pinfo!=NULL)
  4.         delete (pinfo);
  5.     unsigned  long nError;
  6.     nError  =   GetAdaptersInfo(pinfo,&len);
  7.     if (nError==0)
  8.     {
  9.         ParseData();            
  10.     }
  11.     if (nError==ERROR_NO_DATA)
  12.     {
  13.         AfxMessageBox("No adapter information exists for the local computer");
  14.     }
  15.     if (nError==ERROR_NOT_SUPPORTED)
  16.     {
  17.         AfxMessageBox("GetAdaptersInfo is not supported by the operating system running on the local computer");
  18.     }
  19.     if (nError==ERROR_BUFFER_OVERFLOW)
  20.     {
  21.         pinfo= (PIP_ADAPTER_INFO)malloc(len);
  22.         nError  =   GetAdaptersInfo(pinfo,&len);
  23.         if (nError==0)
  24.         {
  25.             ParseData();            
  26.         }
  27.     }
  28.     
  29.     return;
  30. }
  31. void CViewAdapterInfoDlg::ParseData()
  32. {
  33.     if (pinfo!=NULL)
  34.     {
  35.         m_macaddress.Format("%02X:%02X:%02X:%02X:%02X:%02X",pinfo->Address[0],pinfo->Address[1],pinfo->Address[2],pinfo->Address[3],pinfo->Address[4],pinfo->Address[5]);
  36.         m_description   =   pinfo->Description;
  37.         m_type.Format("%d",pinfo->Type);
  38.         
  39.          PIP_ADDR_STRING pAddressList = &(pinfo->IpAddressList);
  40.          m_IpAddress    ="";
  41.           do 
  42.           {
  43.               m_IpAddress   +=  pAddressList->IpAddress.String;
  44.              pAddressList = pAddressList->Next;
  45.              if (pAddressList != NULL)
  46.                 m_IpAddress +="/r/n";
  47.           } while (pAddressList != NULL);
  48.         m_subnet.Format("%s",pinfo->IpAddressList.IpMask.String);
  49.         m_gateway.Format("%s",pinfo->GatewayList.IpAddress.String);
  50.         if (pinfo->HaveWins) 
  51.             m_PrimaryWinsServer.Format("%s",pinfo->PrimaryWinsServer.IpAddress.String );
  52.         else
  53.             m_PrimaryWinsServer.Format("%s","N/A" );
  54.         if (pinfo->DhcpEnabled )
  55.             m_dhcp.Format("%s",pinfo->DhcpServer.IpAddress.String );
  56.         else
  57.             m_dhcp.Format("%s","N/A");
  58.         pinfo = pinfo->Next;
  59.     }
  60.     else
  61.     {
  62.         m_buttonnext.EnableWindow(FALSE);
  63.     }
  64.     UpdateData(FALSE);
  65. }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值