2009-07-04 10 views
2

私たちのアプリケーションはRSSを使用してインターネットからデータをダウンロードしていますが、3Gに接続しているマシンでは接続に問題があります。 3G、EDGE、GPRS接続を検出して、アプリケーションの動作を変更したり、警告や接続状況を表示したりすることができます。.NETで3Gインターネット接続を検出する

これはどのように行われますか? System.Net.NetworkInformation名前空間の

答えて

2

NetworkInterfaceクラスは、より具体的にはあなたにいくつかの使用(、GetAllNetworkInterfaces方法でなければなりません。例をリンクMSDNの種類を取得する方法を示しページ、アドレス、動作ステータス、および他の上に示されていますすべてのネットワークインターフェイスに関する情報

MSDNの例の縮小版:?ネットワーク・インタフェースは、3G/EDGE/GPRSであれば、私が接続しようとした

public static void ShowNetworkInterfaces() 
{ 
    IPGlobalProperties computerProperties = IPGlobalProperties.GetIPGlobalProperties(); 
    NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces(); 
    Console.WriteLine("Interface information for {0}.{1}  ", 
      computerProperties.HostName, computerProperties.DomainName); 
    if (nics == null || nics.Length < 1) 
    { 
     Console.WriteLine(" No network interfaces found."); 
     return; 
    } 

    Console.WriteLine(" Number of interfaces .................... : {0}", nics.Length); 
    foreach (NetworkInterface adapter in nics) 
    { 
     IPInterfaceProperties properties = adapter.GetIPProperties(); 
     Console.WriteLine(); 
     Console.WriteLine(adapter.Description); 
     Console.WriteLine(String.Empty.PadLeft(adapter.Description.Length,'=')); 
     Console.WriteLine(" Interface type .......................... : {0}", adapter.NetworkInterfaceType); 
     Console.WriteLine(" Physical Address ........................ : {0}", 
        adapter.GetPhysicalAddress().ToString()); 
     Console.WriteLine(" Operational status ...................... : {0}", 
      adapter.OperationalStatus); 

     Console.WriteLine(); 
    } 
} 
+0

OKは、これらの特性に基づいて、どのように伝えることができます3GモデムをPCに接続すると、NetworkInterfaceTypeは「Ppp」になります。これは、モバイルコンnection。 –

関連する問題