Hi,
感谢在MSDN论坛发帖。
>>该段代码主要实现计算广播地址的功能,比如电脑IP为192.168.1.20则广播地址应该为192.168.1.255.
在win7上运行正常,但是在win10上则计算出来的广播地址不正确,为255.255.255.255.
你有没有尝试过使用GetAdaptersAddresses函数来代替GetAdaptersInfo?
据我所知,Win10和Win7的区别在于,在Windows 10之前的版本中,适配器在该函数返回的列表中出现的顺序可以从“网络连接文件夹”中控制:从高级菜单中选择“高级设置”菜单项。从Windows 10开始,该顺序不可设置。你可以通过adapter ID来获取信息。
或者你也可以使用WSAIoctl函数,使用SIO_GET_BROADCAST_ADDRESS控制码来获取信息。
希望对你有所帮助。
Best Regards,
Baron Bi
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to
MSDN Support, feel free to contact MSDNFSF@microsoft.com.