我正在开发一个云备份软件。该应用程序是使用C#开发的桌面应用程序。
如果计算机连接到3G网络,我需要添加停止/暂停备份的选项,以便为用户节省成本。
我似乎找不到任何关于如何实现这一点的例子,有一些Windows Phone和Windows Store应用程序的例子,但我找不到任何可以检查连接类型是WiFi/以太网还是3G的东西。后者是我主要关心的。
我尝试了一个测试应用程序来枚举网络:
Console.WriteLine("checking network interfaces\n");
NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces();
foreach (var networkInterface in interfaces)
{
Console.WriteLine("Interface Detected");
Console.WriteLine("Description: "+networkInterface.Description);
Console.WriteLine("ID: " + networkInterface.Id);
Console.WriteLine("Name: " + networkInterface.Name);
Console.WriteLine("Interface Type: " + networkInterface.NetworkInterfaceType);
Console.WriteLine("Operational Status: " + networkInterface.OperationalStatus.ToString());
Console.WriteLine("Speed: " + networkInterface.Speed.ToString());
Console.WriteLine("Supports Multicast: " + networkInterface.SupportsMulticast.ToString());
Console.WriteLine("#########################################################\n");
}上面的代码将我的3G连接列为PPP,它可以是ADSL或3G。我不确定是否可以使用其他选项或API进行区分
我需要一种清晰的方法来区分这些网络,到目前为止,我还找不到这样做的方法。
有人能帮帮忙吗?
发布于 2012-12-25 00:46:13
使用本机WiFi函数获取WiFi接口(WlanEnumInterfaces),使用移动宽带API获取3G接口(IMbnInterfaceManager.GetInterfaces)。较新的3G调制解调器应支持移动宽带API。
https://stackoverflow.com/questions/14021224
复制相似问题