有没有一种方法可以获取和显示C#中应用程序设备的当前无线信号强度?我有一个应用程序可以通过计时器检测是否存在连通性,但是我需要知道当前信号强度,然后在状态栏中以图形方式显示它。下面是我当前的代码,每隔几秒钟检测一次基本连接。我还可以添加什么来显示强度?谢谢。计时器代码由S.O.用户:parapura rajkumar

 private void Form1_Load(object sender, EventArgs e)
    {
        //create an object to hold app settings FIRST

        appsetting apps = new appsetting();
        apps.getsetting();
        netMessage.Clear();

        //creates a timer for refresh rate on connectivity check

         var timer = new Timer();
         timer.Tick += new EventHandler(timer_Tick);
         timer.Interval = 2000; //2 seconds
         timer.Start();
    }


    //starts the timer
 void timer_Tick(object sender, EventArgs e)
 {
    //if connection is not detected
    if (System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable() ==f
    false)
    {
        //clear the buffer
        netMessage.Clear();

        //turn RED indicator on and display message
        netConnect.BackColor = Color.Red;
        this.netMessage.Text = ("No Connection");
        noConn = true;//set "No connection" to true
        conn= false;

    }
    else
        //turn GREEN indicator on and display message
        netConnect.BackColor = Color.Lime;
        this.netMessage.Text = ("Connected");
        conn = true;// set connection to "true
        noConn = false;

            //if box is red but connection is established, turn it back to green


            if (noConn == true &&
            System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable() ==
            true)
            {
                 netConnect.BackColor = Color.Lime;
                 this.netMessage.Text = ("Connected");
                 conn = true;
                 noConn = false;
             }

}


    //need to display signal strength in a text box with color codes or status bar HERE

最佳答案

经过研究并参考了其他一些问题之后,我能够通过以下网址提供的开源API解决我的问题:managedwifi.codeplex.com

只需下载api,然后通过add-> csproj将其添加到您的项目中即可。

使用WlanClient类中提供的“ public int RSSI”。

干杯

关于c# - 在Windows窗体上获取并显示网络信号强度,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11953994/

10-10 07:11