gpt4 book ai didi

c# - 当不存在 MBN 设备时,来自 IMbnInterfaceManager::GetInterfaces 的结果

转载 作者:太空狗 更新时间:2023-10-29 23:50:07 24 4
gpt4 key购买 nike

我有以下代码在 Windows 7 中运行:

            MbnInterfaceManager mbnInfMgr = new MbnInterfaceManager();
IMbnInterfaceManager mbnInfMgrInterface = mbnInfMgr as IMbnInterfaceManager;

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

当 MBN 设备存在时没有问题,但当 MBN 设备不存在时,我在调用 GetInterfaces() 时遇到以下异常:

{System.Runtime.InteropServices.COMException (0x80070490):找不到元素。 (HRESULT 异常:0x80070490) 在 MbnApi.IMbnInterfaceManager.GetInterfaces() 在 foo 中的 foo.Program.configureConnection()

问题在调用 GetInterfaces 之前是否应该做一些事情来检查 MBN 接口(interface)?我可以简单地捕获这个异常,但我找不到任何文档说这个异常与没有接口(interface)是一样的。

我在 statckoverflow 上找到的最接近的是这个 struggling with mobile broadband api windows 7 and windows 8 with C#, not sure what to install这意味着 Windows 7 的行为可能与 Windows 8.1 不同。

最佳答案

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

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

更新:

请注意,我发现您无法像在 Windows 7 中那样在 Windows 8.1 中获取网络信息。参见 How can I install an application that requires WMI capabilities on Windows 8.1 to determine available bandwidth?https://code.msdn.microsoft.com/windowsapps/network-information-sample-63aaa201

关于c# - 当不存在 MBN 设备时,来自 IMbnInterfaceManager::GetInterfaces 的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35065362/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com