经过进一步研究,这似乎是 WMI(Windows 管理基础结构)的一部分
WMI 查询: http:
//msdn.microsoft.com/en-us/library/ms186146 (v=vs.80).aspx
WMI 搜索条件列表:http:
//msdn.microsoft.com/en-us/library/windows/desktop/aa394554 (v=vs.85).aspx
使用 WMI: http:
//msdn.microsoft.com/en-us/library/windows/desktop/aa393964 (v=vs.85).aspx
书籍:
http ://www.amazon.com/s/ref=nb_sb_noss_1?url=search-alias%3Daps&field-keywords=WMI
示例代码:
ManagementObjectSearcher adapters = new ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionStatus = 2");
foreach (ManagementObject item in adapters.Get())
{
foreach (ManagementObject setting in item.GetRelated("Win32_NetworkAdapterConfiguration"))
{
if ((!setting["IPAddress"].IsNull()) &&
(!setting["IPSubnet"].IsNull()))
{
foreach (string value in (String[])setting["IPAddress"])
{
mySocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
mySocket.Bind(new IPEndPoint(IPAddress.Parse(value), 49984));
//etc...
}
}
}
}
总的来说,这似乎是一个相当具有纪念意义的话题,但至少这给了我一个开始尝试理解它的地方。但是,我仍然完全不确定这是否是解决我要解决的问题的好方法。