在同一应用程序中的两个 .csproj 文件之间访问函数

问题描述 投票:0回答:1

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

(Visual Studio 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

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

有什么想法吗?

c# .net csproj
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
    }
    
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.