如何查找板载网络适配器的mac地址 [英] How to find the on board network adapter's mac address

查看:96
本文介绍了如何查找板载网络适配器的mac地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只需要知道当你连接互联网加密狗时如何从可用的mac地址中找到主板的mac地址。

实际上在我的软件中我需要检查主板的mac地址以进行一些安全检查,但是当你的互联网加密狗连接时,你可以通过命令提示符下的ipconfig看到它显示了很多mac地址。

我想如何检查主板的mac地址。



如何找到。

I just need to know that how can you find the mac address of motherboard out of available mac addresses when you connect with your Internet dongle .
Actually in my software I need to check for the motherboard mac address for some security check but when your internet dongle is connected ,you can see through ipconfig under command prompt that it shows many mac addresses .
How i want to check against the motherboard mac address only.

How can I find that .

推荐答案

MAC地址实际上并未连接到主板。它对于网络适配器是唯一的(如果有多个适配器,则每个适配器一个)。有几种方法可以获得此信息。这是一个:



The MAC address is not actually connected to the motherboard. It is unique to the network adapter (one per adapter if there are more than one). There are several ways to do get this info. Here is one:

#include <stdio.h>
#include <WinSock.h>
#pragma comment(lib, "wsock32.lib")

int main(int argc, char *argv[])
{
 WORD wVersionRequested;
 WSADATA wsaData;
 char name[255];
 PHOSTENT hostinfo;
 wVersionRequested = MAKEWORD( 1, 1 );
 char *ip;

 if ( WSAStartup( wVersionRequested, &wsaData ) == 0 )
  if( gethostname ( name, sizeof(name)) == 0)
  {
   printf("Host name: %s\n", name);

   if((hostinfo = gethostbyname(name)) != NULL)
   {
    int nCount = 0;
    while(hostinfo->h_addr_list[nCount])
    {
     ip = inet_ntoa(*(
          struct in_addr *)hostinfo->h_addr_list[nCount]);

     printf("IP #%d: %s\n", ++nCount, ip);
    }
   }
  }
 return 0;
}





另外,在其中 [ ^ ]是一篇关于如何以3种不同的方式获得它。在获得多个答案的情况下,您需要以自己的方式确定所需的方法。



Also, here[^]is an article on how to get it 3 different ways. You need to come up with your own way to determine the one you want in the case that you get multiple answers.


这篇关于如何查找板载网络适配器的mac地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆