任何人都可以给我一个提示,如何在 Windows Phone 8.1. 应用程序(不是 8.0!)上以 C# 方式检测 WLAN 是否启用/禁用? 我不想更改这些设置,只是需要知道...
该解决方案是一个 Windows 8.1 通用应用程序,(Windows Phone 8.1) 项目仅引用 .Net 适用于 Windows 应用商店应用 和 Windows Phone 8.1。 按照建议添加C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\WindowsPhone\v8.1\Microsoft.Phone.dll并查询IsWiFiEnabled属性不起作用 - 编译器错误:在 mscorlib.dll 中找不到类型 System.SystemException
谢谢, 马尔赫
最佳答案
如果您正在寻找非 8.1 Silverlight 解决方案:
您可以使用Windows.Networking.Connectivity
命名空间来查询。
帮助您入门的示例
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;
}
}
关于c# - 检测wlan是否关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26754865/