簡體   English   中英

在桌面應用程序中的Windows 7和8中檢測3G連接

[英]Detecting a 3G connection in Windows 7 and 8 in a desktop application

我正在開發雲備份軟件。 該應用程序是使用C#開發的桌面應用程序。

如果計算機連接到3G網絡,我需要添加一個選項來停止/暫停備份,以節省用戶成本。

我似乎無法找到任何有關如何實現此目標的示例,其中有一些適用於Windows Phone和Windows Store Apps的示例,但是我找不到任何可以檢查連接類型是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來區分

我需要一種清晰的方法來區分這些網絡,到目前為止,我還沒有找到這樣做的方法。

有人可以幫忙嗎?

使用本機WiFi功能獲取WiFi接口(WlanEnumInterfaces),使用移動寬帶API獲取3G接口(IMbnInterfaceManager.GetInterfaces)。 較新的3G調制解調器應支持移動寬帶API。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM