使用NET_FW_SERVICE_REMOTE_DESKTOP类型的INetFwServices中的灾难性故障(来自HRESULT的异常:0x8000FFFF(E_UNEXPECTED))

时间:2016-01-19 20:39:15

标签: interop windows-10 windows-firewall-api

我正在尝试在Windows 10中的INetFwServices元素中进行迭代。但是,当我访问项目服务名称:“远程桌面”类型:NET_FW_SERVICE_REMOTE_DESKTOP时,应用程序抛出异常灾难性故障(HRESULT异常:0x8000FFFF(E_UNEXPECTED))。< / p>

firewall.LocalPolicy.CurrentProfile.Services集合返回3个项目: 1.文件和打印机共享 2.网络发现 3.远程桌面

当我读到第三项“远程桌面”以使其GloballyOpenPorts发生错误时。

在Windows 7中,此类型NET_FW_SERVICE_REMOTE_DESKTOP正常工作,但在Windows 10中失败。如何阅读GloballyOpenPorts of Service Name:Windows 10中的“远程桌面”?

progID = Type.GetTypeFromProgID("HNetCfg.FwMgr");
            firewall = Activator.CreateInstance(progID) as INetFwMgr;
            ports = firewall.LocalPolicy.CurrentProfile.GloballyOpenPorts;

            Debug.WriteLine("Count Services: " +  firewall.LocalPolicy.CurrentProfile.Services.Count);

            foreach (INetFwService service in firewall.LocalPolicy.CurrentProfile.Services)
            {
                Debug.WriteLine("Service: " + service.Name);

                var port = service.GloballyOpenPorts;
            }

StackTrace:在NetFwTypeLib.INetFwService.get_GloballyOpenPorts()    在FirewallCustomTest.Firewall.isPortFound(Int32 portNumber)中的c:\ Users \ Smartmatic \ Documents \ Visual Studio 2012 \ Projects \ FirewallCustomTest \ FirewallCustomTest \ Firewall.cs:第178行

0 个答案:

没有答案