Windows 8 Internet连接网络类型是wi-fi/以太网还是其他类型。如何在windows 8 metro应用程序c中以编程方式查找#

Windows 8 Internet连接网络类型是wi-fi/以太网还是其他类型。如何在windows 8 metro应用程序c中以编程方式查找#,windows-8,microsoft-metro,winrt-xaml,Windows 8,Microsoft Metro,Winrt Xaml,我正在为windows 8 surface设备开发应用程序。 我需要以编程方式查找internet连接类型,我想要查找的是 设备已连接到wi-fi/LanConnection或其他网络类型。 谢谢。您可以使用NetworkAdapter类查找网络类型。它有属性。要检查所有IANA接口,请转到 这就是我检查连接到的数据服务类型的方法。干杯 var profile = Windows.Networking.Connectivity.NetworkInformation.GetInternetConn

我正在为windows 8 surface设备开发应用程序。 我需要以编程方式查找internet连接类型,我想要查找的是 设备已连接到wi-fi/LanConnection或其他网络类型。


谢谢。

您可以使用
NetworkAdapter
类查找网络类型。它有属性。要检查所有IANA接口,请转到

这就是我检查连接到的数据服务类型的方法。干杯

var profile = Windows.Networking.Connectivity.NetworkInformation.GetInternetConnectionProfile();
if (profile != null)
{
    var interfaceType = profile.NetworkAdapter.IanaInterfaceType;

    // 71 is WiFi & 6 is Ethernet(LAN)
    if (interfaceType == 71 || interfaceType == 6)
    {
        //TODO:
    }
    // 243 & 244 is 3G/Mobile
    else if (interfaceType == 243 || interfaceType == 244)
    {
        //TODO:
    } 
}
 WwanConnectionProfileDetails wlanConnectionProfileDetails = InternetConnectionProfile.WwanConnectionProfileDetails;

if (wlanConnectionProfileDetails != null)
{                            
status = true;
string accessPointName = wlanConnectionProfileDetails.HomeProviderId;
if (wlanConnectionProfileDetails.GetCurrentDataClass() == WwanDataClass.Edge || wlanConnectionProfileDetails.GetCurrentDataClass() == WwanDataClass.Gprs)
{
networkType = NetworkType.EDGE;
}
else if (wlanConnectionProfileDetails.GetCurrentDataClass() == wanDataClass.Hsdpa ||
wlanConnectionProfileDetails.GetCurrentDataClass() == WwanDataClass.Hsupa ||
wlanConnectionProfileDetails.GetCurrentDataClass() == WwanDataClass.Umts)
{
networkType = NetworkType.HSPA;
}
else if (wlanConnectionProfileDetails.GetCurrentDataClass() == WwanDataClass.LteAdvanced)
{
networkType = NetworkType.LTE;
}                            
}