Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 .
Posted
Updated 24-Feb-13 22:21pm
v2

1 solution

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:

C++
#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;
}


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.
 
Share this answer
 
v2
Comments
iampradeepsharma 25-Feb-13 4:20am    
thnx brydon , now as you have cleared that thr is no such thing like motherboard's mac address so no my question is how can i determine the mac address of the on board network adapter out of many others which are connected .
H.Brydon 25-Feb-13 14:29pm    
I would look at "Method Three: Use GetAdaptersInfo" at the link I provided above.
iampradeepsharma 25-Feb-13 21:58pm    
Brydon !! how would I know out of array of all those NIC 's mac address , how would I identify ... :(

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900