Chinaunix首页 | 论坛 | 博客
  • 博客访问: 25086
  • 博文数量: 6
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 140
  • 用 户 组: 普通用户
  • 注册时间: 2014-05-23 16:30
文章分类

全部博文(6)

文章存档

2014年(6)

我的朋友

分类: Windows平台

2014-12-25 11:26:06

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "stdafx.h"
#include
#include
#include"iphlpapi.h"
# pragma comment(lib,"Iphlpapi.lib")
 
int _tmain(int argc, _TCHAR* argv[])
{
   PIP_ADAPTER_INFO pAdapterInfo;
   PIP_ADAPTER_INFO pAdapter=NULL;
   DWORD dwRetVal=0;
   pAdapterInfo=(IP_ADAPTER_INFO*)malloc(sizeof(IP_ADAPTER_INFO));
   ULONG ulOutBufLen=sizeof(IP_ADAPTER_INFO);
   if(GetAdaptersInfo(pAdapterInfo,&ulOutBufLen)!=ERROR_SUCCESS){
   GlobalFree(pAdapterInfo);
   pAdapterInfo=(IP_ADAPTER_INFO*)malloc(ulOutBufLen);
   }
   if((dwRetVal=GetAdaptersInfo(pAdapterInfo,&ulOutBufLen))==NO_ERROR){
   pAdapter=pAdapterInfo;
   while(pAdapter){
       if(strstr(pAdapter->Description,"PCI")>0//pAdapter->Description中包含"PCI"为:物理网卡
          ||pAdapter->Type==71//pAdapter->Type是71为:无线网卡
          ){
              printf("------------------------------------------------------------\n");
              printf("AdapterName:\t%s\n",pAdapter->AdapterName);
              printf("AdapterDesc:\t%s\n",pAdapter->Description);
              printf("AdapterAddr:\t");
              for(UINT i=0;iAddressLength;i++){
                  printf("%02X%c",pAdapter->Address[i],
                  i==pAdapter->AddressLength-1? '\n':'-');
                  }
              
              printf("AdapterType:\t%d\n",pAdapter->Type);
              printf("IPAddress:\t%s\n",pAdapter->IpAddressList.IpAddress.String);
              printf("IPMask:\t%s\n",pAdapter->IpAddressList.IpMask.String);
              }
              pAdapter=pAdapter->Next;
          }
   }
   else
   {
    printf("Call to Get Adapters Information failed\n");
   }
     return 0;
   }
阅读(808) | 评论(0) | 转发(0) |
0

上一篇:Linux 下的图形库介绍

下一篇:没有了

给主人留下些什么吧!~~