PC내의 유선 또는 무선 네트워크 어댑터로부터 모든 Mac Address를 가져오는 샘플입니다.

 

간단하게 MFC의 CStringArray에 어드레스를 할당하는데, 적당히 활용하면 될 것으로 보입니다.

void CUtility::GetMacAddress(CStringArray& addresss)

{

           IP_ADAPTER_INFO AdapterInfo[16];        

           DWORD dwBufLen = sizeof (AdapterInfo); 

 

           DWORD dwStatus = GetAdaptersInfo(AdapterInfo, &dwBufLen);             

          if (dwStatus == NO_ERROR)

           {

                     PIP_ADAPTER_INFO pAdapterInfo = AdapterInfo; 

                    while (pAdapterInfo)

                     {

                                CStringA strMacAddress;

                                strMacAddress.Format("%02X:%02X:%02X:%02X:%02X:%02X",

                pAdapterInfo->Address[0],

                pAdapterInfo->Address[1],

                pAdapterInfo->Address[2],

                pAdapterInfo->Address[3],

                                    pAdapterInfo->Address[4],

                pAdapterInfo->Address[5]); 

                                addresss.Add(CA2T(strMacAddress));

                                pAdapterInfo = pAdapterInfo->Next;    // 다으 링크

                     }                           

           }

}