头文件IPApi.h
#pragma once
// Returns number of NICs
// 'address' contains the physical address of index='idx'
int get_physical_address(char * address, int idx);
// Returns number of NICs
// 'address' contains the physical address of index=0
int get_first_physical_address(char * address);
bool is_physical_address(const char * address);
源文件IPApi.cpp
#include "IPApi.h"
#include <winsock2.h>
#include <iphlpapi.h>
#include <stdio.h>
#include <stdlib.h>
#pragma comment(lib, "IPHLPAPI.lib")
#define WORKING_BUFFER_SIZE 15000
#define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x))
#define FREE(x) HeapFree(GetProcessHeap(), 0, (x))
static void phy_adapter_address2str(PIP_ADAPTER_ADDRESSES paddress, char * saddress) {
int j = 0;
for (int i = 0; i < (int)paddress->PhysicalAddressLength; i++) {
j += sprintf(saddress + j, &#