日期:2014-05-20  浏览次数:20732 次

怎样查看本机的端口信息(c#)
怎样查看本机的端口信息(c#)
不是用netstat命令,是用c#程序实现.

------解决方案--------------------
C#运行netstat,获取返回结果,获得用系统API。
------解决方案--------------------
http://www.codeproject.com/useritems/portscan.asp

*****************************************************************************
欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码)

最新版本:20070212

http://www.cnblogs.com/feiyun0112/archive/2006/09/20/509783.html
------解决方案--------------------
就是通过线程运行netstat,
参考下面:
Process p = new Process();

p.StartInfo.FileName = "cmd.exe ";

p.StartInfo.UseShellExecute = false;

p.StartInfo.RedirectStandardInput = true;

p.StartInfo.RedirectStandardOutput = true;

p.StartInfo.RedirectStandardError = true;

p.StartInfo.CreateNoWindow = true;
p.Start ();


p.StandardInput.WriteLine( "netsh ");
p.StandardInput.WriteLine( "interface ");
p.StandardInput.WriteLine( "ip ");
p.StandardInput.WriteLine(a.ToString ());
p.StandardInput.WriteLine( "exit ");
p.StandardInput.WriteLine( "exit ");
p.Close ();