当前位置:   article > 正文

c语言编程修改mac地址,怎么通过C语言自动生成MAC地址

c语言修改window网卡mac地址

//   MAC.c

#include

#include

#include

#include

#define RANDOM(x) (rand()%x)

#define MAC_ADDR_LENGTH 12

#define FMT_MAC_ADDR_LEN (MAC_ADDR_LENGTH+5)

unsigned char HEXCHAR[16]={'0','1','2','3','4','5','6','7','8','9','A','B','C',

'D','E','F'};

unsigned char genMACAddr[MAC_ADDR_LENGTH];

unsigned char fmtMACAddr[FMT_MAC_ADDR_LEN]={'0','0','-','0','0','-','0','0','-',

'0','0','-','0','0','-','0','0'};

void formatMACAddr()

{

unsigned short i=0;

unsigned short n=0;

for(i=0;i

{

if(fmtMACAddr[n]!='-')

{

fmtMACAddr[n]=genMACAddr[i];

}

else

{

n++;

fmtMACAddr[n]=genMACAddr[i];

}

}

}

void main()

{

unsigned short i=0;

unsigned short n=0;

srand(getpid());

for(int i=0;i

{

n=RANDOM(16);

genMACAddr[i]=HEXCHAR[n];

}

formatMACAddr();

printf("%s",fmtMACAddr);

}

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/548343
推荐阅读
相关标签
  

闽ICP备14008679号