コード例 #1
0
        public static void GetNetworkList(NLM_ENUM_NETWORK Flags)
        {
            foreach (INetwork Network in INetworkListMgr.GetNetworks(Flags))
            {
                System.Text.StringBuilder builder = new System.Text.StringBuilder();
                builder.AppendLine($"Name: {Network.GetName()}");
                builder.AppendLine($"Description: {Network.GetDescription()}");
                builder.AppendLine($"ID: {Network.GetNetworkId()}");
                builder.AppendLine($"Is connected: {Network.IsConnected}");
                builder.AppendLine($"Is connected to internet: {Network.IsConnectedToInternet}");

                switch (Network.GetCategory())
                {
                case NLM_NETWORK_CATEGORY.NLM_NETWORK_CATEGORY_PUBLIC:
                    builder.AppendLine("Category: PUBLIC");
                    break;

                case NLM_NETWORK_CATEGORY.NLM_NETWORK_CATEGORY_PRIVATE:
                    builder.AppendLine("Category: PRIVATE");
                    break;

                case NLM_NETWORK_CATEGORY.NLM_NETWORK_CATEGORY_DOMAIN_AUTHENTICATED:
                    builder.AppendLine("Category: DOMAIN_AUTHENTICATED");
                    break;
                }
                switch (Network.GetConnectivity())
                {
                case NLM_CONNECTIVITY.NLM_CONNECTIVITY_DISCONNECTED:
                    builder.AppendLine("Connectivity: DISCONNECTED");
                    break;

                case NLM_CONNECTIVITY.NLM_CONNECTIVITY_IPV4_NOTRAFFIC:
                    builder.AppendLine("Connectivity: IPV4_NOTRAFFIC");
                    break;

                case NLM_CONNECTIVITY.NLM_CONNECTIVITY_IPV6_NOTRAFFIC:
                    builder.AppendLine("Connectivity: IPV6_NOTRAFFIC");
                    break;

                case NLM_CONNECTIVITY.NLM_CONNECTIVITY_IPV4_SUBNET:
                    builder.AppendLine("Connectivity: IPV4_SUBNET");
                    break;

                case NLM_CONNECTIVITY.NLM_CONNECTIVITY_IPV4_LOCALNETWORK:
                    builder.AppendLine("Connectivity: IPV4_LOCALNETWORK");
                    break;

                case NLM_CONNECTIVITY.NLM_CONNECTIVITY_IPV4_INTERNET:
                    builder.AppendLine("Connectivity: IPV4_INTERNET");
                    break;

                case NLM_CONNECTIVITY.NLM_CONNECTIVITY_IPV6_SUBNET:
                    builder.AppendLine("Connectivity: IPV6_SUBNET");
                    break;

                case NLM_CONNECTIVITY.NLM_CONNECTIVITY_IPV6_LOCALNETWORK:
                    builder.AppendLine("Connectivity: IPV6_LOCALNETWORK");
                    break;

                case NLM_CONNECTIVITY.NLM_CONNECTIVITY_IPV6_INTERNET:
                    builder.AppendLine("Connectivity: IPV6_INTERNET");
                    break;

                default:
                    builder.AppendLine("Connectivity: CONNECTED");
                    break;
                }
                switch (Network.GetDomainType())
                {
                case NLM_DOMAIN_TYPE.NLM_DOMAIN_TYPE_NON_DOMAIN_NETWORK:
                    builder.AppendLine("DomainType: NON_DOMAIN_NETWORK");
                    break;

                case NLM_DOMAIN_TYPE.NLM_DOMAIN_TYPE_DOMAIN_NETWORK:
                    builder.AppendLine("DomainType: DOMAIN_NETWORK");
                    break;

                case NLM_DOMAIN_TYPE.NLM_DOMAIN_TYPE_DOMAIN_AUTHENTICATED:
                    builder.AppendLine("DomainType: DOMAIN_AUTHENTICATED");
                    break;
                }
                Trace.WriteLine(builder.ToString());
            }
        }
コード例 #2
0
 public virtual extern IEnumNetworks GetNetworks([In] NLM_ENUM_NETWORK Flags);