• C#检测网卡和网络统计信息


    using System;
    using System.Collections.Generic;
    using System.Net.NetworkInformation;
    
    public class MyClass
    {
        public static void Main()
        {
            //Host Info
            IPGlobalProperties  ipProp = IPGlobalProperties.GetIPGlobalProperties();
            string hostInfo = 
                string.Format("Host Name:{0}
    Domain Name:{1}
    
    ",ipProp.HostName,ipProp.DomainName);
            //statistics
            IPGlobalStatistics ipStat = ipProp.GetIPv4GlobalStatistics();
            TcpConnectionInformation[] tcpConns = ipProp.GetActiveTcpConnections();
            string stat="";
            foreach(TcpConnectionInformation info in tcpConns)
                stat += string.Format("localhost:{0}	{1}:{2}	state:{3}", info.LocalEndPoint.Port,
                info.RemoteEndPoint.Address,info.RemoteEndPoint.Port, info.State);
            //Network Interface
            string niInfo="";
            NetworkInterface[] nis = NetworkInterface.GetAllNetworkInterfaces();
            foreach(NetworkInterface ni in nis)
                niInfo += string.Format("
    
    Name:{0}
    Status:{1}
    Speed:{2}
    MAC:{3}", 
                ni.Name,ni.OperationalStatus,ni.Speed,ni.GetPhysicalAddress());
    
            System.Windows.Forms.MessageBox.Show(hostInfo + niInfo);        
            System.Windows.Forms.MessageBox.Show(stat);        
            Console.ReadKey();
        }
    }
  • 相关阅读:
    Automated Telephone Exchange
    Babelfish
    又见回文
    487-3279
    Robot Motion
    99. Recover Binary Search Tree
    98. Validate Binary Search Tree
    97. Interleaving String
    96. Unique Binary Search Trees
    95. Unique Binary Search Trees II
  • 原文地址:https://www.cnblogs.com/flaaash/p/3599304.html
Copyright © 2020-2023  润新知