GetAdaptersInfo & GetAdaptersAddresses

Posted 代码如诗

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了GetAdaptersInfo & GetAdaptersAddresses相关的知识,希望对你有一定的参考价值。

I use GetAdaptersInfo to get MAC addresses of interfaces.
 
GetAdaptersInfo exist on old and new versions of Windows. 
But msdn warns :
    "On Windows XP and later:  Use the GetAdaptersAddresses 
      function instead of GetAdaptersInfo."
Why ? I suspect it is because GetAdaptersAddresses  adds ipv6; GetAdaptersInfo does not have ipv6 addresses.
But I do not need ipv6 addresses.
 
It is difficult to use GetAdaptersAddresses because W2k does not have GetAdaptersAddresses . I need to support w2 and newer oses, too, so here is my question.
 
Is there sesious reason to prefer GetAdaptersAddresses to GetAdaptersInfo when getting MAC addresses of interfaces ?
 
Hi Viki,

To me, it sounds like perhaps GetAdaptersInfo may be dropped at some future point.  Your code could detect W2K and use GetAdaptersInfo, and on XP+ use GetAdaptersAddresses.  I suppose, it comes down to whether you do the work now, or when / if GetAdaptersInfo is dropped. 

以上是关于GetAdaptersInfo & GetAdaptersAddresses的主要内容,如果未能解决你的问题,请参考以下文章

GetAdaptersInfo怎样区分无线网卡

请教下为何MSDN里查不到GetAdaptersInfo这个API,

vb.net 第一节 获取本机网络适配器的信息 GetAdaptersInfo

如何在 C++ 中读取 Windows 默认网关 IP 地址

VC 电脑的有线网卡与无线网卡的IP区别

POST & GET & Ajax 全解