如何判断电脑是否有wifi适配器?

How to determine if the computer has a wifi adapter?

我可以通过哪种方式确定计算机是否有 wifi 适配器?
当我测试我的代码时它可以工作,但我不确定它是否会一直工作?

private bool hasWifi()
{
    try
    {
        WlanClient wlanclient = new WlanClient();
    }
    catch (System.ComponentModel.Win32Exception except)
    {
        return false;
    }

    return true;
}

你可以用NetworkInterface.GetAllNetworkInterfaces看看安装了什么。

private bool hasWifi()
{
    return NetworkInterface.GetAllNetworkInterfaces()
        .Any(nic => nic.NetworkInterfaceType == NetworkInterfaceType.Wireless80211);
}