1

我将 Codeplex 的 Managed WiFi 站点提供的 WLAN API 合并到我的 C# 项目(Windows 窗体应用程序)中。在 API 中,提供了不同的函数来检索机器当前 WiFi 配置文件的各个方面。我只对检索下面函数中给出的 RSSI 强度感兴趣。然后,我想获取该值并将其粘贴在表单上的文本框中。

(视觉工作室 2008)

在 WlanAPI.cs 文件中,我感兴趣的函数是这样存在的:

 namespace NativeWifi
{
   public class WlanClient
{
    /// <summary>
    /// Represents a Wifi network interface.
    /// </summary>
    public class WlanInterface
    {

                   /// <summary>
        /// Gets the RSSI.
        /// </summary>
        /// <value>The RSSI.</value>
        /// <remarks>Not supported on Windows XP SP2.</remarks>
        public int RSSI
        {
            get
            {
                return GetInterfaceInt(Wlan.WlanIntfOpcode.RSSI);
            }
        }

在 myApp.cs 中,我有一个简单命名为“wifi”的文本框,它将显示当前的 RSSI。我在 myApp.cs 标头中包含:“使用 NativeWifi”,但似乎无法从 WlanAPI.csproj 中的 RSSI 函数获取数据。该项目构建和编译得很好。我只是想获得 RSSI 值。

在 myApp.cs 我有一个声明,大意是:

wifi.Text = (GetInterfaceInt(Wlan.WlanIntfOpcode.RSSI)); //app form txt_box=RSSI value

我知道这是不正确的,但显示了我正在尝试做的事情。

有任何想法吗?

谢谢。

4

1 回答 1

2

你应该能够解决你所面临的问题

  1. 添加对 WlanAPI.dll 或 WlanAPI 项目的引用(如果将其添加到解决方案中)
  2. 使用如下代码:

    Using NativeWifi;
    
    Class MyAPP : Form
    {
    
      public void PrintRSSI()
      {
    
          WlanClient client = new WlanClient();
          var interfaces = client.Interfaces;
    
          //Now chose an interface out of all the available interfaces. Usually there would be zero or 1 interfaces available
          if(interfaces.Length > 0)
          {
              //Select first available interface. A more complicated logic can present the list of available interfaces to the user and and then display RSSI for the selected interface
              wifi.Text = interfaces[0].RSSI.ToString();
          }
       }
    
     //Other code for the class
    }
    
于 2012-08-17T12:21:31.147 回答