-->

如何识别一个孤网(How to identify an Isolated Network)

2019-10-17 08:23发布

我开发C#.NET3.5应用。

该应用程序使用检查文件的签名的WinVerifyTrust 。 问题是,在独立的网络(即无法上网,但该机还具有IP地址),需要花费很长的时间(约20秒),直到返回的WinVerifyTrust。

有没有一种方法,以确定这种情况呢?

Answer 1:

您是否尝试过使用Windows API -

using System;
using System.Runtime;
using System.Runtime.InteropServices;

    public class InternetCS
    {
        //Creating the extern function...
        [DllImport("wininet.dll")]
        private extern static bool InternetGetConnectedState( out int Description, int ReservedValue );

        //Creating a function that uses the API function...
        public static bool IsConnectedToInternet( )
        {
            int Desc ;
            return InternetGetConnectedState( out Desc, 0 ) ;
        }
    }


Answer 2:

以及如何将分化如果计算机与互联网连接速度较慢连接?

反正你可以平谷歌(举例来说),看它是否是可用的。 如果电脑不是孤立它可用。

从C#ping通只是使用System.Net.NetworkInformation.Ping

编辑 :如果你需要支持是后面的代理,那么你应该打开过谷歌一个80端口的TcpConnection和检查,如果你能或者不能。 如果你不能打开一个端口,谷歌的80您无法连接到任何的WinVerifyTrust。



文章来源: How to identify an Isolated Network