#include "stdio.h"
#include "pcap.h"
#include "remote-ext.h"
#include<string.h>
//#include "IPHlpApi.h"
#pragma comment(lib,"wpcap")
#pragma comment(lib,"iphlpapi.lib")
void specificcard(pcap_if_t *dev);
void main()
{
pcap_if_t *alldevs;
pcap_if_t *d;
int i=0;
char errbuf[PCAP_ERRBUF_SIZE];
/* 获取本地机器设备列表 */
if (pcap_findalldevs(&alldevs, errbuf) == -1)
//if (pcap_findalldevs_ex(PCAP_SRC_IF_STRING , NULL/* auth is not needed */, &alldevs, errbuf) == -1)
{
fprintf(stderr,"Error in pcap_findalldevs_ex: %s\n", errbuf);
exit(1);
}
/* 打印列表 */
for(d= alldevs; d != NULL; d= d->next)
{
printf("%d. %s\n", ++i, d->name);
if (d->description)
{
printf(" (%s)\n", d->description);
specificcard(d);
}
else
printf(" (No description available)\n");
}
if (i == 0)
{
printf("\nNo interfaces found! Make sure WinPcap is installed.\n");
return;
}
/* 不再需要设备列表了,释放它 */
pcap_freealldevs(alldevs);
}
void specificcard(pcap_if_t *dev)
{
//char str2[256];
//char *str2=new char[];
//str2=dev;
//while(*dev->name!='{')
//{
//if(*dev->name==NULL)
//break;
//dev++;
//}
//int i=0;
// while(*dev->name!='}')
// {
//*str2=*dev->name;
//(dev->name)++;
// str2++;
//str2[i++];
//}
//printf("%s",str2);
//delete[] str2;
//PIP_ADAPTER_INFO pAdapterInfo;
//DWORD GetAdaptersInfo ( pAdapterInfo, PULONG pOutBufLen );
HKEY hKey;
char buffer1[256];
sprintf(buffer1,"SYSTEM\\ControlSet001\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\%s\\Connection",dev->name);
LPCTSTR path=buffer1;//="SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\{70584D65-EFEA-49BC-911D-88E7F675AEE5}\\Connection";
RegOpenKey(HKEY_LOCAL_MACHINE,path,&hKey);
DWORD dwType;
DWORD dwValue;
DWORD dwAge;
RegQueryValueEx(hKey,"MediaSubType",0,&dwType,(LPBYTE)&dwAge,&dwValue);
//CString str;
//str.Format("MediaSubType=%d",dwAge);
//MessageBox(str);
printf("MediaSubType=%d\n",dwAge);
RegCloseKey(hKey);
}