不存在MBN设备时,IMbnInterfaceManager :: GetInterfaces的结果 [英] hresult from IMbnInterfaceManager::GetInterfaces when no MBN device exists
问题描述
我在Windows 7中使用以下代码:
I have the following code working in Windows 7:
MbnInterfaceManager mbnInfMgr = new MbnInterfaceManager();
IMbnInterfaceManager mbnInfMgrInterface = mbnInfMgr as IMbnInterfaceManager;
if (mbnInfMgrInterface != null)
{
IMbnInterface[] mobileInterfaces = mbnInfMgrInterface.GetInterfaces() as IMbnInterface[];
}
当存在MBN设备但不存在MBN设备时没有问题在调用GetInterfaces()时遇到以下异常:
No problems when the MBN device exists but when an MBN device doesn't exist I get the following exception in the call to GetInterfaces():
{System.Runtime.InteropServices.COMException(0x80070490):找不到元素。 (来自HRESULT的异常:0x80070490)
在MbnApi.IMbnInterfaceManager.GetInterfaces()
在foo.Program.configureConnection()在}}
{System.Runtime.InteropServices.COMException (0x80070490): Element not found. (Exception from HRESULT: 0x80070490) at MbnApi.IMbnInterfaceManager.GetInterfaces() at foo.Program.configureConnection() in foo}
问题
在调用GetInterfaces之前是否应该做一些检查MBN接口的事情?我可以简单地捕获此异常,但找不到任何文档说明该异常与没有接口相同。
Question Is there something that should be done to check for a MBN interface before calling GetInterfaces? I can simply catch this exception but I can't find any documentation that says this exception is the same as having no interfaces.
我在statckoverflow上找到的最接近的东西是此
使用C#在移动宽带api Windows 7和Windows 8上苦苦挣扎,不确定要安装什么
,这意味着Windows 7的行为可能不同于Windows 8.1。
The closest thing I have found on statckoverflow is this struggling with mobile broadband api windows 7 and windows 8 with C#, not sure what to install which implies that maybe windows 7 behaves differently than windows 8.1.
推荐答案
我尝试使用GetSignalStrength()和MbnInterfaceManager遇到相同的 Element not c异常,但我发现可以使用WMI获得很多有用的信息。请使用
SELECT * FROM Win32_PerfRawData_Tcpip_NetworkInterface
在这里查看答案:
I got the same Element not found
exception trying to use GetSignalStrength() and MbnInterfaceManager I instead found you can obtain a lot of useful info using WMI. Please see the answer here using SELECT * FROM Win32_PerfRawData_Tcpip_NetworkInterface
:
与移动宽带api Windows 7和Windows进行斗争8使用C#,不确定要安装什么
更新:
请注意,我发现您无法以与Windows 7中相同的方式在Windows 8.1中获得网络信息。请参阅需要wmi-capabilities-on的应用程序的安装?如何在Windows 8.1上安装需要WMI功能的应用程序才能确定可用带宽?和 https://code.msdn.microsoft.com/windowsapps / network-informati on-sample-63aaa201
Please note that I found you cannot get the network info in Windows 8.1 in the same way as you do in Windows 7. See How can I install an application that requires WMI capabilities on Windows 8.1 to determine available bandwidth? and https://code.msdn.microsoft.com/windowsapps/network-information-sample-63aaa201
这篇关于不存在MBN设备时,IMbnInterfaceManager :: GetInterfaces的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!