何を求めているのか正確にはわかりませんが、IMbnInterface と GetSignalStrength() に苦労した後 ( https://msdn.microsoft.com/en-us/library/windows/desktop/dd323166(v=vs.85).aspxを参照)失敗しましたが、WMI を使用して多くの情報を取得できることがわかりました。
int maxBandwidth = 0;
string query = "SELECT * FROM Win32_PerfRawData_Tcpip_NetworkInterface";
ManagementObjectSearcher moSearch = new ManagementObjectSearcher(query);
ManagementObjectCollection moCollection = moSearch.Get();
foreach (ManagementObject mo in moCollection)
{
if (Convert.ToInt32(mo["CurrentBandwidth"]) > maxBandwidth)
{
// Instead of CurrentBandwidth you may want to use BytesReceivedPerSec
maxBandwidth = Convert.ToInt32(mo["CurrentBandwidth"]);
}
}
ここで回答を参照してください:ネットワーク接続のリンク速度を決定する。取得できるプロパティのリストは次のとおりです: https://msdn.microsoft.com/en-us/library/aa394293(VS.85).aspx
アップデート:
Windows 7 または Windows 8.1 のいずれかで Visual Studio 2015 内から上記のコードを (より大きな WPF アプリケーションの一部として) ビルドおよびデバッグでき、同じアプリケーションを Windows 7 に展開して正常に実行できることに注意してください。このアプリケーションを Windows 8.1 にデプロイすると、何らかの理由でInvalid query
メッセージが表示されます。
更新 2:
System.Management
Windows 8.1 では名前空間を使用できないため、Windows 7 と同じ方法で Windows 8.1 でネットワーク情報を取得できないことがわかりました。https://code.msdn.microsoft.com/windowsapps/network-information-sample-63aaa201を参照してください
string connectionProfileInfo = string.Empty;
ConnectionProfile InternetConnectionProfile = NetworkInformation.GetInternetConnectionProfile();
if (InternetConnectionProfile == null)
{
rootPage.NotifyUser("Not connected to Internet\n", NotifyType.StatusMessage);
}
else
{
connectionProfileInfo = GetConnectionProfile(InternetConnectionProfile);
OutputText.Text = connectionProfileInfo;
rootPage.NotifyUser("Success", NotifyType.StatusMessage);
}
// Which calls this function, that allows you to determine how strong the signal is and the associated bandwidth
string GetConnectionProfile(ConnectionProfile connectionProfile)
{
// ...
if (connectionProfile.GetSignalBars().HasValue)
{
connectionProfileInfo += "====================\n";
connectionProfileInfo += "Signal Bars: " + connectionProfile.GetSignalBars() + "\n";
}
// ...
}