更新时间:2023-01-27 11:34:51
如果您正在寻找非8.1 Silverlight解决方案:
If you're looking for a Non 8.1 Silverlight solution:
您可以使用 Windows.Networking.Connectivity
命名空间进行查询。
You can use the Windows.Networking.Connectivity
namespace to query this.
一个入门示例
bool is_wifi_enabled = false;
Guid adapter_id = new Guid();
// get the list of connection profiles
// we need the adpater id for the wifi
foreach (var item in NetworkInformation.GetConnectionProfiles())
{
// check if wifi
if (item.IsWlanConnectionProfile)
{
// tag the adapter
adapter_id = item.NetworkAdapter.NetworkAdapterId;
}
}
// get all lan adapters (this most likely will be empty if wlan is disabled)
foreach (var item in NetworkInformation.GetLanIdentifiers())
{
if (item.NetworkAdapterId == adapter_id)
{
is_wifi_enabled = true;
}
}