Giter Site home page Giter Site logo

intersting's Introduction

VC获取MAC地址

给出使用VC读取机器MAC地址的方法,能有效解决读取虚拟机、云主机、Docker和实体机获取真实MAC问题。

常用方法测试

1.通过GetAdaptersInfo获取

2.通过ipconfig/all命令获取,然后通过管道方式获取输出结果,并对结果进行分析处理

3.使用Windows的SNMP(简单网络管理协议)扩展来取得MAC地址,据说是只有安装了该协议的才能获取,本人没有测试

4.使用Microsoft的Netbios API。 这是一套通过Winsock提供底层网络支持的命令。使用Netbios的最大缺点是您必须在系统中安装了Netbios服务

5.使用COM GUID API。这种方法比较不靠谱,有时获取的是随机的十六进制数

区分物理网卡和虚拟网卡:pAdapter->Description中包含"PCI"是:物理网卡

区分无线网卡和有线网卡:pAdapter->Type为71的是:无线网卡

以上方法均有问题,可能在部分机型测试正常,在大量机器值测试就会发现潜在的问题

测试代码

代码使用Visual Studio 2013测试正常,程序如果在VC中使用,部分函数需要调整,调整后的程序在VC中测试正常,此工程未给出VC的代码,如有需求,自行更改。

如果修改了机器的MAC地址,使用MAC.cpp中注册表内容读取的MAC值,仍然为修改前的MAC,精确度更高。如果想获取到修改后的MAC地址,可以使用另一个文件。

intersting's People

Contributors

zhenyuwei avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.