网上很多的用VC读取MAC代码都没用,坑害了不少新手朋友,我在这里把网上流传的一些错误版本进行了整合和纠错,在这里把有效代码贴出来,有疑问欢迎提出。 // Mac-Reader.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <windows.h> #include <wincon.h> #include <nb30.h> // 因为是通过NetAPI来获取网卡信息,所以需要包含其题头文件nb30.h #include <stdlib.h> #include <stdio.h> #include <time.h> typedef struct _ASTAT_ { ADAPTER_STATUS adapt; NAME_BUFFER NameBuff [30]; }ASTAT, * PASTAT; ASTAT Adapter; // 定义一个存放返回网卡信息的变量 // 输入参数:lana_num为网卡编号,一般地,从0开始,但在Windows 2000中并不一定是连续分配的 void getmac_one (int lana_num) { NCB ncb; UCHAR uRetCode; memset( &ncb, 0, sizeof(ncb) ); ncb.ncb_command = NCBRESET; ncb.ncb_lana_num = lana_num; // 指定网卡号 // 首先对选定的网卡发送一个NCBRESET命令,以便进行初始化 uRetCode = Netbios( &ncb ); printf( "Th