我使用下面的代码来检测Internet连接类型。如何检测WinRT应用程序的Internet连接类型
我尝试以下条件:
- 断开无线上网为笔记本
- 用于笔记本
问题断开有线互联网连接: 与上述图1和2的条件,将码仍然产生了一个结果: 接口类型6(“Internet连接(电缆))。这怎么可能?
我尝试这样做,结果是一样的:
- 连接到WiFi网络
- 断开电缆连接互联网
我怎么错过?
private async void btnChkConnectionType_Click(object sender, RoutedEventArgs e) { var profile = Windows.Networking.Connectivity.NetworkInformation.GetInternetConnectionProfile(); var interfaceType = profile.NetworkAdapter.IanaInterfaceType; // 71 is WiFi & 6 is Ethernet if (interfaceType == 71) { txtBlkConnectionStatus.Text = "WiFi connection"; } else if(interfaceType == 6) { txtBlkConnectionStatus.Text = "Internet connection (cable)"; } //3G/Mobile Detect else if (interfaceType == 243 || interfaceType == 244) { txtBlkConnectionStatus.Text = "Mobile Connection"; } else { txtBlkConnectionStatus.Text = "Not common connection type."; } }
JS,请不要让答案看起来像问题。我编辑它相应,因为它看起来像一个答案(不是评论)。谢谢。 – Drew