由于终端设备多网卡使用的问题,以前使用Netbios()获取网卡MAC地址的方法可能导致不可靠的问题。
现推荐大家使用如下方法实现:
CString GetLicense(CString strMac)
{
int P1=0, P2=0, P3=0, P4=0, P5=0, P6=0;
sscanf(strMac, "% 02X% 02X% 02X% 02X% 02X% 02X", &P1, &P2, &P3, &P4, &P5, &P6);
int nTemp = P1+P2+P3+P4+P5+P6;
CString strAdd;
strAdd.Format("% 02X% 02X", nTemp/6, nTemp%0xFF);
return strMac+strAdd;
}
CString GetMacByName(CString strName)
{
CString strName2=strName+":";
char szFile[512], szCmd[512];
memset(szFile, 0x00, sizeof(szFile));
if(!GetSystemDirectory(szFile, sizeof(szFile)))
{
获取指定网卡的MAC地址
最新推荐文章于 2025-05-02 14:29:41 发布
本文介绍了如何在C++中通过ipconfig命令获取指定网卡的MAC地址,提供了两个函数GetMacByName和GetLicense,前者从ipconfig输出中解析MAC地址,后者计算MAC地址的校验和作为附加信息。

最低0.47元/天 解锁文章
4238

被折叠的 条评论
为什么被折叠?



