5

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[];
            }

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): Element not found. (Exception from HRESULT: 0x80070490) at MbnApi.IMbnInterfaceManager.GetInterfaces() at foo.Program.configureConnection() in foo}

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.

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.

4

1 回答 1

0

我在Element not found尝试使用 GetSignalStrength() 和 MbnInterfaceManager 时遇到了同样的异常,我发现您可以使用 WMI 获得很多有用的信息。请在此处查看答案SELECT * FROM Win32_PerfRawData_Tcpip_NetworkInterface

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

更新:

请注意,我发现您无法像在 Windows 7 中那样在 Windows 8.1 中获取网络信息。请参阅如何在 Windows 8.1 上安装需要 WMI 功能的应用程序以确定可用带宽?https://code.msdn.microsoft.com/windowsapps/network-information-sample-63aaa201

于 2017-03-27T23:43:22.753 回答