int EnumHardWareMAC() { HRESULT hrVal; HKEY pHKey = NULL; hrVal = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE//Microsoft//Windows NT//CurrentVersion//NetworkCards"), 0, KEY_ALL_ACCESS, &pHKey); if(hrVal == ERROR_SUCCESS) { TCHAR sz[256]; DWORD i=0; while(RegEnumKey(pHKey, i++, sz, 255) == ERROR_SUCCESS) { HKEY pHKeyEx=0; hrVal = RegOpenKeyEx(pHKey, sz, 0, KEY_ALL_ACCESS, &pHKeyEx); if(hrVal == ERROR_SUCCESS) { int j=0; while(1) { TCHAR szName[256]; DWORD dwName=255; BYTE szVal[256]; DWORD dwVal=255; DWORD nType; hrVal = RegEnumValue(pHKeyEx, j++, szName, &dwName, 0, &nType, szVal, &dwVal); if(hrVal== ERROR_SUCCESS) { TRACE(_T("%s=>%s/r/n"), szName, szVal); } else break; } DWORD nType; BYTE ServeUUID[256] = {0}; DWORD dwSize=255; hrVal = RegQueryValueEx(pHKeyEx, _T("ServiceName"), 0, &nType, ServeUUID, &dwSize); if(hrVal == ERROR_SUCCESS) { HANDLE hHandle = 0; TCHAR DevName[256] = _T("//./"); _tcscat(DevName, (TCHAR*)ServeUUID); hHandle=CreateFile(DevName, 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0 , NULL); if(hHandle != INVALID_HANDLE_VALUE) { DWORD dw=0; DWORD IOCTL_NDIS_QUERY_GLOBAL_STATS = 0x00170002; int OID_802_3_PERMANENT_ADDRESS = 0x01010101; BYTE outBuf[256]={0}; if(DeviceIoControl(hHandle, IOCTL_NDIS_QUERY_GLOBAL_STATS, &OID_802_3_PERMANENT_ADDRESS,4, outBuf,256, &dw, NULL)) { TRACE(_T("%02X-%02X-%02X-%02X-%02X-%02X/r/n"), (WORD)outBuf[0], (WORD)outBuf[1], (WORD)outBuf[2], (WORD)outBuf[3], (WORD)outBuf[4], (WORD)outBuf[5]); //outBuf dw } CloseHandle(hHandle); } } RegCloseKey(pHKeyEx); } } RegCloseKey(pHKey); } return 0; }