[英]detect if wlan is turned off
誰能給我一個提示,如何在Windows Phone 8.1上以編程方式在C#中進行檢測。 應用程序(不是8.0!),是否啟用/禁用了WLAN? 我不想更改這些設置,只需要知道...
該解決方案是Windows 8.1通用應用程序,並且(Windows Phone 8.1)項目僅引用.Net用於Windows Store Apps和Windows Phone 8.1 。 根據建議添加C:\\ Program Files(x86)\\ Reference Assemblies \\ Microsoft \\ Framework \\ WindowsPhone \\ v8.1 \\ Microsoft.Phone.dll並查詢IsWiFiEnabled屬性不起作用-編譯器錯誤:在以下位置找不到類型System.SystemException mscorlib.dll中
謝謝,Marher
如果您正在尋找非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;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.