How do I get the available wifi APs and their signal strength in .net?

后端 未结 7 1263
我寻月下人不归
我寻月下人不归 2020-11-28 05:00

Is there any way to access all WiFi access points and their respective RSSI values using .NET? It would be really nice if I could do it without using unmanaged code or even

7条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-28 05:20

    If the platform is Windows10, you can use Microsoft.Windows.SDK.Contracts package to access all available wifis.

    First, install Microsoft.Windows.SDK.Contracts package from nuget.

    Then, you can use next code to get ssid and signal strength.

    var adapters = await WiFiAdapter.FindAllAdaptersAsync();
    foreach (var adapter in adapters)
    {
        foreach (var network in adapter.NetworkReport.AvailableNetworks)
        {
            Console.WriteLine($"ssid: {network.Ssid}");
            Console.WriteLine($"signal strength: {network.SignalBars}");
        }
    }
    

提交回复
热议问题