标签:des style blog io color ar sp div on
//数组的大小只能是13
1 GetMacAdress(char arr[],int Num){ 2 char MAC[13]={0}; 3 PIP_ADAPTER_INFO pAdapterInfo; 4 PIP_ADAPTER_INFO pAdapter = NULL; 5 DWORD dwRetVal = 0; 6 pAdapterInfo = (IP_ADAPTER_INFO*)malloc(sizeof(IP_ADAPTER_INFO)); 7 ULONG ulOutBufLen = sizeof(IP_ADAPTER_INFO); 8 if(GetAdaptersInfo(pAdapterInfo,&ulOutBufLen) != ERROR_SUCCESS) 9 { 10 free(pAdapterInfo); 11 pAdapterInfo=(IP_ADAPTER_INFO*)malloc(ulOutBufLen); 12 13 } 14 if((dwRetVal=GetAdaptersInfo(pAdapterInfo,&ulOutBufLen)) == NO_ERROR) 15 { 16 pAdapter = pAdapterInfo; 17 while(pAdapter) 18 { 19 if(strstr(pAdapter->Description,"PCI")) 20 { 21 sprintf_s(MAC,"%02X%02X%02X%02X%02X%02X",pAdapter->Address[0],pAdapter->Address[1],pAdapter->Address[2],pAdapter->Address[3],pAdapter->Address[4],pAdapter->Address[5]); 22 strcpy_s(arr,Num,MAC); 23 24 } 25 pAdapter=pAdapter->Next; 26 } 27 }else{ 28 strcpy_s(MAC,sizeof(MAC),"NONE"); 29 strcpy_s(arr,Num,MAC); 30 } 31 }
标签:des style blog io color ar sp div on
原文地址:http://www.cnblogs.com/kingbin/p/4074246.html