我正在开发用于Windows 8表面设备的应用程序。 我需要以编程方式找到我想要找到的互联网连接类型 设备连接到wi-fi / LanConnection或其他一些网络类型。
谢谢。
答案 0 :(得分:6)
您可以找到NetworkAdapter
类的网络类型。它有财产IanaInterfaceType。要检查所有IANA界面,请转到here
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:
}
}
答案 1 :(得分: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;
}
}
这是我检查连接的数据服务类型的方法。干杯!!