确定连接的接入点信息 [英] Determining Connected Access Point Information

查看:91
本文介绍了确定连接的接入点信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发Windows Mobile应用程序,该应用程序将在有时连接的环境中使用.该应用程序的设计参数之一是监视网络连接的状态,以确定是缓存数据还是保存到服务器.另一个参数是跟踪设备连接到哪个接入点(AP)(因为这可以让我们知道设备在设施中的哪个位置运行).

使用OpenNETCF智能设备框架(2.3版),我可以轻松确定连接状态.我还可以快速获取设备可以看到"的所有AP的列表.

现在,...从我可以捕获的适配器信息中,我可以获得所连接的AP的SSID.对于我正在使用的环境,因为我们对所有AP都有通用的SSID,所以这无法帮助我确定连接到哪个AP(假设可以看到多个AP).

我真正需要得到的是AP的MAC地址或分配的名称.

关于如何实现这一目标的任何想法?

是否有获取此信息的替代方法???想法???

请注意,我已将此类似问题发布到其他论坛,包括MSDN(http://social.msdn.microsoft.com/Forums/en-US/vssmartdevicesvbcs/thread/f534081a-a55f-4c48-b358-7cad5a9d562f)

I am developing a Windows Mobile application that will be used in a sometimes connected environment. One of the design parameters of the application is to monitor the state of the network connection to determine whether to cache data or to save to the server. Another parameter is to track which Access Point (AP) the device is connected to (as this lets us know where in the facility the device is operating).

Using the OpenNETCF Smart Device Framework (version 2.3) I''m easilly able to determine connection status. I can also quickly get a list of all of the APs that the device can ''see''.

Now,... from the Adaptor information that I can capture I can get the SSID for the AP I am connected to. For the environment I am working with this does not help me to determine which AP I am connected to (assuming more than one is visible) as we have a common SSID for all APs.

What I really need to get is the MAC address or the assigned name of the AP.

Any ideas on how to achieve this?

Is there an alternate method to get this information??? Ideas???

Note I''ve posted this similar question to other forums including MSDN (http://social.msdn.microsoft.com/Forums/en-US/vssmartdevicesvbcs/thread/f534081a-a55f-4c48-b358-7cad5a9d562f)

推荐答案

好吧,....通过愚蠢的运气,反复试验和of强,我找到了使用OpenNETCF.Net一直在寻找的东西:

Okay,.... through dumb luck, trial and error and a bit of stubbornness I''ve found what I''ve been looking for using OpenNETCF.Net:

private void ShowAdaptors()
{
  OpenNETCF.Net.NetworkInformation.WirelessNetworkInterface IN;
  OpenNETCF.Net.NetworkInformation.WirelessZeroConfigNetworkInterface INw;

  listBox1.Items.Clear();

  foreach (OpenNETCF.Net.NetworkInformation.INetworkInterface ni in OpenNETCF.Net.NetworkInformation.WirelessNetworkInterface.GetAllNetworkInterfaces())
  {
    listBox1.Items.Add("Desc: " + ni.Description);
    listBox1.Items.Add("IP: " + ni.CurrentIpAddress );
    listBox1.Items.Add("ID: " + ni.Id );
    listBox1.Items.Add("Status: " + ni.InterfaceOperationalStatus);
    listBox1.Items.Add("Type: " + ni.NetworkInterfaceType);

    if (ni is OpenNETCF.Net.NetworkInformation.WirelessNetworkInterface) listBox1.Items.Add("Is Wireless");
    if (ni is OpenNETCF.Net.NetworkInformation.WirelessZeroConfigNetworkInterface) listBox1.Items.Add("Is WZC");

    if (ni is OpenNETCF.Net.NetworkInformation.WirelessZeroConfigNetworkInterface )
    {  // wireless zero config.
      INw = (OpenNETCF.Net.NetworkInformation.WirelessZeroConfigNetworkInterface)ni;
      listBox1.Items.Add(" AP: " + INw.AssociatedAccessPoint);
      listBox1.Items.Add(" AP MAC: " + INw.AssociatedAccessPointMAC.ToString());
    }
    else if (ni is OpenNETCF.Net.NetworkInformation.WirelessNetworkInterface )
    {  // wireless network
      IN = (OpenNETCF.Net.NetworkInformation.WirelessNetworkInterface)ni;
      listBox1.Items.Add(" AP: " + IN.AssociatedAccessPoint);
      listBox1.Items.Add(" AP MAC: " + IN.AssociatedAccessPointMAC.ToString());
    }
  }
}



并不是曾经编写过的最漂亮的代码(主要是因为我仍在提高C#的速度),但它确实执行了我想要的功能.



Not the prettiest code ever written (mainly as I am still coming up to speed on C#) but it does perform the function I was looking for.


这篇关于确定连接的接入点信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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