如何获取硬件MAC地址在Windows上 [英] How to get hardware MAC address on Windows

查看:321
本文介绍了如何获取硬件MAC地址在Windows上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在玩NIC从网卡检索MAC地址 - 有各种各样的方法来获取它,本文涵盖最常见的:



< a href =http://www.codeguru.com/Cpp/IN/network/networkinformation/articles.php/c5451> http://www.codeguru.com/Cpp/IN/network/networkinformation/article.php / c5451



我目前使用的GetAdaptersInfo方法,这似乎是最防弹,但如果MAC地址已通过注册表设置: p>

http://www.mydigitallife.info/2008/06/30/how-to-change-or-spoof- mac-address-in-windows-xp-vista-server-20032008-mac-os-x-unix-and-linux /



已更改为的MAC地址。我发现实际获得真正的MAC唯一的方法是删除注册表项,重新启动NIC,通过GetAdaptersInfo获取MAC,然后替换注册表项,并重新启动NIC。虽然它完成了工作,但对用户来说是不透明的。



有任何人都熟悉的任何其他方法,将返回硬件MAC,无论什么注册表设置为?理想情况下,我想要一个在XP上工作的解决方案。



提前感谢!

解决方案

我的猜测是,在链接的CodeGuru文章中,Miniport解决方案很可能克服你描述的问题,虽然痛苦的实现。我认为这是因为我已经使用GetAdaptersInfo解决方案自己过去,并注意到MAC地址将更改,而不会重新启动,当添加适配器,例如。提供PAN服务的蓝牙适配器。



也许而不是在更改注册表设置后重新启动,您可以尝试停止并重新启动相关的网络服务。您可以在寻找程序化解决方案之前手动检查此操作。



(上面的所有内容都是猜测的工作,如果您尝试它,对于那些试图在未来做同样的)。


I'm playing around with retrieving the MAC address from the NIC - there are a variety of ways to get it, this article covers the most common:

http://www.codeguru.com/Cpp/I-N/network/networkinformation/article.php/c5451

I'm currently using the GetAdaptersInfo method, which seems the most bulletproof, but if the MAC address has been set via the registry:

http://www.mydigitallife.info/2008/06/30/how-to-change-or-spoof-mac-address-in-windows-xp-vista-server-20032008-mac-os-x-unix-and-linux/

Then it reports the MAC address that it has been changed to. The only way I've found to actually get the true MAC is to remove the registry entry, restart the NIC, get the MAC via GetAdaptersInfo, then replace the registry entry, and restart the NIC. While it gets the job done, it's hardly transparent to the user.

Is there any other methods that anyone is familiar with, that will return the hardware MAC regardless of what the registry is set to? Ideally I'd like a solution that works on XP on up.

Thanks in advance!

解决方案

My guess is that in the linked CodeGuru article, the Miniport solution is likely to overcome the problem you describe, albeit painful to implement. The reason I think this is that I have used the GetAdaptersInfo solution myself in the past, and noticed that the MAC address will change without reboot when an adapter is added, e.g. a Bluetooth adapter providing PAN services.

Perhaps rather than rebooting after changing the registry setting, you could try stopping and restarting the relevent network services. You could easily check this manually prior to looking for a programmatic solution.

(n.b. the above is all guess work. If you try it and it works, perhaps add a post for those trying to do the same in future).

这篇关于如何获取硬件MAC地址在Windows上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆