#pragma comment(lib, "IPHLPAPI.lib")
static void GetMACaddress(void)
{
IP_ADAPTER_INFO AdapterInfo[16];
DWORD dwBufLen = sizeof(AdapterInfo);
DWORD dwStatus = GetAdaptersInfo(AdapterInfo,&dwBufLen);
assert(dwStatus == ERROR_SUCCESS);
PIP_ADAPTER_INFO pAdapterInfo = AdapterInfo;
char macaddress[13];
char tempmacaddress[3];
do{
sprintf(macaddress,"");
printf("%s",pAdapterInfo->AdapterName);
for(int i=0; i
{
if(i== (pAdapterInfo->AddressLength -1))
{
sprintf(tempmacaddress,"%.2X",(int)pAdapterInfo->Address[i]);
strcat(macaddress, tempmacaddress);
//printf("%.2X\n",(int)pAdapterInfo->Address[i]);
}else{
sprintf(tempmacaddress,"%.2X",(int)pAdapterInfo->Address[i]);
strcat(macaddress, tempmacaddress);
//printf("%.2X-",(int)pAdapterInfo->Address[i]);
}
}
printf(macaddress);
pAdapterInfo = pAdapterInfo->Next;
}while(pAdapterInfo);
}
No comments:
Post a Comment