1 #include "stdafx.h" 2 #include "windows.h" 3 #include "wincon.h" 4 #include "stdlib.h" 5 #include "stdio.h" 6 #include "time.h" 7 #include "nb30.h" 8 #pragma comment(lib,"netapi32.lib") 9 10 typedef struct _ASTAT_ 11 { 12 ADAPTER_STATUS adapt; 13 NAME_BUFFER NameBuff[30]; 14 }ASTAT,*PASTAT; 15 16 ASTAT Adapter; 17 18 void getmac_one(int lana_num) 19 { 20 NCB ncb; 21 UCHAR uRetCode; 22 memset(&ncb,0,sizeof(ncb)); 23 ncb.ncb_command=NCBRESET; 24 ncb.ncb_lana_num=lana_num; 25 uRetCode=Netbios(&ncb); 26 printf("The ncbreset return code is: 0x%x \n",uRetCode); 27 memset(&ncb,0,sizeof(ncb)); 28 ncb.ncb_command=NCBASTAT; 29 ncb.ncb_lana_num=lana_num; 30 strcpy((char*)ncb.ncb_callname,"*"); 31 ncb.ncb_buffer=(unsigned char *) &Adapter; 32 ncb.ncb_length=sizeof(Adapter); 33 uRetCode=Netbios(&ncb); 34 printf("The ncbastat return code is:0x%x\n",uRetCode); 35 if (uRetCode==0) 36 { 37 printf("The ethernet number[%d] is :%02x%02x-%02x%02x-%02x%02x\n",lana_num, 38 Adapter.adapt.adapter_address[0], 39 Adapter.adapt.adapter_address[1], 40 Adapter.adapt.adapter_address[2], 41 Adapter.adapt.adapter_address[3], 42 Adapter.adapt.adapter_address[4], 43 Adapter.adapt.adapter_address[5]); 44 } 45 } 46 int main(int argc, char* argv[]) 47 { 48 NCB ncb; 49 UCHAR uRetCode; 50 LANA_ENUM lana_enum; 51 memset(&ncb,0,sizeof(ncb)); 52 ncb.ncb_command=NCBENUM; 53 ncb.ncb_buffer=(unsigned char *)&lana_enum; 54 ncb.ncb_length=sizeof(lana_enum); 55 56 57 uRetCode=Netbios(&ncb); 58 printf("the ncbenum return code is:0x%x\n",uRetCode); 59 if (uRetCode==0) 60 { 61 printf("ethernet cout is :%d\n\n",lana_enum.length); 62 for (int i=0;i<lana_enum.length;++i) 63 { 64 getmac_one(lana_enum.lana[i]); 65 } 66 } 67 system("pause"); 68 return 0; 69 }
......