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