2

我正在为 Windows 8 表面设备开发应用程序。我需要以编程方式找到互联网连接类型我想要找到的是设备连接到 wi-fi/LanConnection 或其他网络类型。

谢谢你。

4

2 回答 2

6

您可以找到带有NetworkAdapter类的网络类型。它有属性IanaInterfaceType。要检查所有 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:
    } 
}
于 2013-07-05T06:07:02.400 回答
1
 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;
}                            
}

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

于 2015-05-19T04:38:34.880 回答