#include <IPHlpApi.h> // for GetAdaptersInfo()
#pragma comment(lib, “iphlpapi.lib” )
// MAC 가져오기
CString GetMACAddress()
{
CString strMac;
DWORD size = sizeof(PIP_ADAPTER_INFO);
PIP_ADAPTER_INFO Info;
ZeroMemory( &Info, size );
int result = GetAdaptersInfo( Info, &size ); // 첫번째 랜카드 MAC address 가져오기
if (result == ERROR_BUFFER_OVERFLOW) // GetAdaptersInfo가 메모리가 부족하면 재 할당하고 재호출
{
Info = (PIP_ADAPTER_INFO)malloc(size);
GetAdaptersInfo( Info, &size );
}
if(!Info)
return strMac;
strMac.Format(“%0.2X-%0.2X-%0.2X-%0.2X-%0.2X-%0.2X”, Info->Address[0], Info->Address[1], Info->Address[2], Info->Address[3], Info->Address[4], Info->Address[5] );
return strMac;
}
{
CString strMac;
DWORD size = sizeof(PIP_ADAPTER_INFO);
{
Info = (PIP_ADAPTER_INFO)malloc(size);
GetAdaptersInfo( Info, &size );
}
return strMac;
}