使用C#与移动宽带api windows 7和Windows 8挣扎,不知道要安装什么

我有一个需要控制移动宽带API的应用程序。

我正在努力在我的设备上正确安装api。

我一直按照本文档中的说明操作:

http://www.google.be/url?sa=t&rct=j&q=&esrc=s&frm=1&source=web&cd=1&cad=rja&ved=0CC0QFjAA&url=http%3A%2F%2Fdownload.microsoft.com%2Fdownload%2F7%2FE% 2F7%2F7E7662CF-CBEA-470B-A97E-CE7CE0D98DC2%2FMB_ManagedCode.docx&EI = kyvmUs7jE4e60QWbooHYDg&USG = AFQjCNG6yaGf4sRhdbWI99fE7tmQX8cmnA&SIG2 = 2FG-_DRYBIselKR19wTq2Q

并尝试将这些步骤与此stackoverflow解释相结合

C#读取Windows Mobile宽带连接属性

我已经能够在V7.0 / lib中将visual studio的参考文献放到mbnapi.tlb中。 我现在自动在我的obj / debug文件夹中有一个interop.mbnapi.tlb。

尝试“检查SIM卡是否已插入并正在工作/激活”时。 =>我的代码在以下行崩溃

IMbnInterface[] mobileInterfaces = mbnInfMgrInterface.GetInterfaces() as IMbnInterface[]; 

当我在Windows 8上运行它时,mbnInfMgrInterface == null

我已经尝试在Windows 8上安装相同的SDK,如文档要求中所述,但SDK仅适用于Windows 7 …

我试图通过执行在Windows 8中注册mbnapi

 Regtlibv12 Mbnapi.tlb 

没有运气……

我需要做些什么才能让它发挥作用?

谁有这方面的经验?

编辑。 在Windows 7(我的开发机器)上,我收到消息“设备未准备好”,我认为这是正常的,因为我没有移动宽带,在Windows 8上我做,但移动界面管理器是null = > mbnInfMgrInterface == null。

谢谢,

不确定你到底是什么,但在与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:

请注意,我发现您无法像在Windows 7中那样获取Windows 8.1中的网络信息,因为Windows 8.1上没有System.Management命名空间。 请参阅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"; } // ... }