Which way can I decide the computer has a wifi adapter?
When I test my code it works, but I am uncertain, will it always work?
private bool hasWifi()
{
try
{
WlanClient wlanclient = new WlanClient();
}
catch (System.ComponentModel.Win32Exception except)
{
return false;
}
return true;
}
You can use the NetworkInterface.GetAllNetworkInterfaces to look at what is installed.
private bool hasWifi()
{
return NetworkInterface.GetAllNetworkInterfaces()
.Any(nic => nic.NetworkInterfaceType == NetworkInterfaceType.Wireless80211);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With