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;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;
}
|