Hresult of IMbnInterfaceManager :: GetInterfaces when there is no MBN device

I have the following code running on Windows 7:

MbnInterfaceManager mbnInfMgr = new MbnInterfaceManager(); IMbnInterfaceManager mbnInfMgrInterface = mbnInfMgr as IMbnInterfaceManager; if (mbnInfMgrInterface != null) { IMbnInterface[] mobileInterfaces = mbnInfMgrInterface.GetInterfaces() as IMbnInterface[]; } 

There is no problem when the MBN device exists, but when the MBN device does not exist, I get the following exception in the call to GetInterfaces ():

{System.Runtime.InteropServices.COMException (0x80070490): The item was not found. (Exception from HRESULT: 0x80070490) in MbnApi.IMbnInterfaceManager.GetInterfaces () in foo.Program.configureConnection () in foo}

Question Is there something that needs to be done to check the MBN interface before calling GetInterfaces? I can just catch this exception, but I cannot find the documentation that says this exception is the same as the lack of interfaces.

The closest I found in statckoverflow is struggling with mobile broadband api windows 7 and windows 8 with C #, not sure what to install, that maybe Windows 7 behaves differently than Windows 8.1.

+5
source share
1 answer

I have the same Element not found exception that is trying to use GetSignalStrength () and MbnInterfaceManager. Instead, you can get a lot of useful information using WMI. See the answer here using SELECT * FROM Win32_PerfRawData_Tcpip_NetworkInterface :

struggling with mobile broadband api windows 7 and windows 8 with C #, not sure what to install

UPDATE:

Please note that I found that you cannot get network information in Windows 8.1 in the same way as in Windows 7. See How to install an application that requires Windows 8.1 WMI capabilities to determine the available bandwidth? and https://code.msdn.microsoft.com/windowsapps/network-information-sample-63aaa201

0
source

Source: https://habr.com/ru/post/1241727/


All Articles