C#检测网卡和网络统计信息
2024-08-30 09:49:32
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}\nDomain Name:{1}\n\n",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}\t{1}:{2}\tstate:{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("\n\nName:{0}\nStatus:{1}\nSpeed:{2}\nMAC:{3}",
ni.Name,ni.OperationalStatus,ni.Speed,ni.GetPhysicalAddress()); System.Windows.Forms.MessageBox.Show(hostInfo + niInfo);
System.Windows.Forms.MessageBox.Show(stat);
Console.ReadKey();
}
}
最新文章
- jsp通过易宝方式实现在线支付
- 请问MVC4是不是类似于html页+ashx页之间用JSON通过AJAX交换数据这种方式、?
- jar包合并
- Android SDK打包
- 希尔排序(C++版)
- 详细说明svn分支与合并---命令行
- OpenXML操作word
- vim命令总结
- Phpwind v9.0 存储型xss跨站漏洞
- 【转】ubuntu连接android设备(附最简单方法)
- python学习第八天 -- 迭代
- ViewDragHelper练习使用
- 调用微信退款接口时,证书验证出现System.Security.Cryptography.CryptographicException: 出现了内部错误 解决办法
- 基于Handler架构的录音程序
- 2018-2019-2 网络对抗技术 20165316 Exp4 恶意代码分析
- 关于SVD
- Java如何创建参数个数不限的函数
- 【cocos2d-x 3.0-Mac配置篇】
- php 分享一个object(stdclass)转数组的函数
- Floyd模板(详细操作最基础版)