ソースを参照

添加查看网络连接工具

yuzhengyang 8 年 前
コミット
6250e9ddb9

+ 0 - 1
Fork.Net/Oreo.CleverDog/FodyWeavers.xml

@@ -1,5 +1,4 @@
 <?xml version="1.0" encoding="utf-8"?>
 <Weavers>
 	<Costura/>
-  
 </Weavers>

+ 2 - 2
Fork.Net/Oreo.CleverDog/Oreo.CleverDog.csproj

@@ -105,18 +105,18 @@
     </ProjectReference>
   </ItemGroup>
   <ItemGroup>
-    <Content Include="FodyWeavers.xml" />
+    <None Include="FodyWeavers.xml" />
     <Content Include="Images\Backgrounds\Rocket.png" />
     <Content Include="Images\Icons\CleverDog.ico" />
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <Import Project="..\packages\Fody.2.0.9\build\portable-net+sl+win+wpa+wp\Fody.targets" Condition="Exists('..\packages\Fody.2.0.9\build\portable-net+sl+win+wpa+wp\Fody.targets')" />
   <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
     <PropertyGroup>
       <ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
     </PropertyGroup>
     <Error Condition="!Exists('..\packages\Fody.2.0.9\build\portable-net+sl+win+wpa+wp\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.2.0.9\build\portable-net+sl+win+wpa+wp\Fody.targets'))" />
   </Target>
-  <Import Project="..\packages\Fody.2.0.9\build\portable-net+sl+win+wpa+wp\Fody.targets" Condition="Exists('..\packages\Fody.2.0.9\build\portable-net+sl+win+wpa+wp\Fody.targets')" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.
   <Target Name="BeforeBuild">

+ 0 - 1
Fork.Net/Oreo.NetMonitor/FodyWeavers.xml

@@ -1,5 +1,4 @@
 <?xml version="1.0" encoding="utf-8"?>
 <Weavers>
 	<Costura/>
-  
 </Weavers>

+ 0 - 39
Fork.Net/Oreo.NetMonitor/Form1.Designer.cs

@@ -1,39 +0,0 @@
-namespace Oreo.NetMonitor
-{
-    partial class Form1
-    {
-        /// <summary>
-        /// 必需的设计器变量。
-        /// </summary>
-        private System.ComponentModel.IContainer components = null;
-
-        /// <summary>
-        /// 清理所有正在使用的资源。
-        /// </summary>
-        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
-        protected override void Dispose(bool disposing)
-        {
-            if (disposing && (components != null))
-            {
-                components.Dispose();
-            }
-            base.Dispose(disposing);
-        }
-
-        #region Windows 窗体设计器生成的代码
-
-        /// <summary>
-        /// 设计器支持所需的方法 - 不要修改
-        /// 使用代码编辑器修改此方法的内容。
-        /// </summary>
-        private void InitializeComponent()
-        {
-            this.components = new System.ComponentModel.Container();
-            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.Text = "Form1";
-        }
-
-        #endregion
-    }
-}
-

+ 0 - 20
Fork.Net/Oreo.NetMonitor/Form1.cs

@@ -1,20 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-
-namespace Oreo.NetMonitor
-{
-    public partial class Form1 : Form
-    {
-        public Form1()
-        {
-            InitializeComponent();
-        }
-    }
-}

+ 14 - 7
Fork.Net/Oreo.NetMonitor/Oreo.NetMonitor.csproj

@@ -35,6 +35,9 @@
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
+  <PropertyGroup>
+    <ApplicationManifest>Properties\app.manifest</ApplicationManifest>
+  </PropertyGroup>
   <ItemGroup>
     <Reference Include="CapturePackage">
       <HintPath>..\Dlls\CapturePackage\CapturePackage.dll</HintPath>
@@ -53,12 +56,6 @@
   <ItemGroup>
     <Compile Include="Commons\P.cs" />
     <Compile Include="Commons\R.cs" />
-    <Compile Include="Form1.cs">
-      <SubType>Form</SubType>
-    </Compile>
-    <Compile Include="Form1.Designer.cs">
-      <DependentUpon>Form1.cs</DependentUpon>
-    </Compile>
     <Compile Include="Helpers\SendHelper.cs" />
     <Compile Include="Models\NetProcess.cs" />
     <Compile Include="Models\ProcessPort.cs" />
@@ -89,6 +86,12 @@
     <Compile Include="Views\NetReportForm.Designer.cs">
       <DependentUpon>NetReportForm.cs</DependentUpon>
     </Compile>
+    <Compile Include="Views\TestForm.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="Views\TestForm.Designer.cs">
+      <DependentUpon>TestForm.cs</DependentUpon>
+    </Compile>
     <Compile Include="Views\WelcomeForm.cs">
       <SubType>Form</SubType>
     </Compile>
@@ -117,6 +120,10 @@
     <EmbeddedResource Include="Views\NetReportForm.resx">
       <DependentUpon>NetReportForm.cs</DependentUpon>
     </EmbeddedResource>
+    <EmbeddedResource Include="Views\TestForm.resx">
+      <DependentUpon>TestForm.cs</DependentUpon>
+    </EmbeddedResource>
+    <None Include="Properties\app.manifest" />
     <None Include="packages.config" />
     <None Include="Properties\Settings.settings">
       <Generator>SettingsSingleFileGenerator</Generator>
@@ -138,7 +145,7 @@
     </ProjectReference>
   </ItemGroup>
   <ItemGroup>
-    <Content Include="FodyWeavers.xml" />
+    <None Include="FodyWeavers.xml" />
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <Import Project="..\packages\Fody.2.0.9\build\portable-net+sl+win+wpa+wp\Fody.targets" Condition="Exists('..\packages\Fody.2.0.9\build\portable-net+sl+win+wpa+wp\Fody.targets')" />

+ 75 - 0
Fork.Net/Oreo.NetMonitor/Properties/app.manifest

@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="utf-8"?>
+<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
+  <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
+  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
+    <security>
+      <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
+        <!-- UAC 清单选项
+             如果想要更改 Windows 用户帐户控制级别,请使用
+             以下节点之一替换 requestedExecutionLevel 节点。n
+        <requestedExecutionLevel  level="asInvoker" uiAccess="false" />
+        <requestedExecutionLevel  level="requireAdministrator" uiAccess="false" />
+        <requestedExecutionLevel  level="highestAvailable" uiAccess="false" />
+
+            指定 requestedExecutionLevel 元素将禁用文件和注册表虚拟化。
+            如果你的应用程序需要此虚拟化来实现向后兼容性,则删除此
+            元素。
+        -->
+        <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
+      </requestedPrivileges>
+    </security>
+  </trustInfo>
+
+  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
+    <application>
+      <!-- 设计此应用程序与其一起工作且已针对此应用程序进行测试的
+           Windows 版本的列表。取消评论适当的元素,Windows 将
+           自动选择最兼容的环境。 -->
+
+      <!-- Windows Vista -->
+      <!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
+
+      <!-- Windows 7 -->
+      <!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
+
+      <!-- Windows 8 -->
+      <!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
+
+      <!-- Windows 8.1 -->
+      <!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
+
+      <!-- Windows 10 -->
+      <!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
+
+    </application>
+  </compatibility>
+
+  <!-- 指示该应用程序可以感知 DPI 且 Windows 在 DPI 较高时将不会对其进行
+       自动缩放。Windows Presentation Foundation (WPF)应用程序自动感知 DPI,无需
+       选择加入。选择加入此设置的 Windows 窗体应用程序(目标设定为 .NET Framework 4.6 )还应
+       在其 app.config 中将 "EnableWindowsFormsHighDpiAutoResizing" 设置设置为 "true"。-->
+  <!--
+  <application xmlns="urn:schemas-microsoft-com:asm.v3">
+    <windowsSettings>
+      <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
+    </windowsSettings>
+  </application>
+  -->
+
+  <!-- 启用 Windows 公共控件和对话框的主题(Windows XP 和更高版本) -->
+  <!--
+  <dependency>
+    <dependentAssembly>
+      <assemblyIdentity
+          type="win32"
+          name="Microsoft.Windows.Common-Controls"
+          version="6.0.0.0"
+          processorArchitecture="*"
+          publicKeyToken="6595b64144ccf1df"
+          language="*"
+        />
+    </dependentAssembly>
+  </dependency>
+  -->
+
+</assembly>

+ 6 - 2
Fork.Net/Oreo.NetMonitor/Views/MainForm.cs

@@ -9,6 +9,7 @@ using System.Diagnostics;
 using System.Drawing;
 using System.Linq;
 using System.Net;
+using System.Runtime.InteropServices;
 using System.Text;
 using System.Threading;
 using System.Threading.Tasks;
@@ -25,9 +26,12 @@ namespace Oreo.NetMonitor.Views
         }
         private void MainForm_Load(object sender, EventArgs e)
         {
-            FloatForm ff = new FloatForm();
-            ff.Show();
+            //FloatForm ff = new FloatForm();
+            //ff.Show();
+
+            new TestForm().Show();
         }
 
+
     }
 }

+ 65 - 0
Fork.Net/Oreo.NetMonitor/Views/TestForm.Designer.cs

@@ -0,0 +1,65 @@
+namespace Oreo.NetMonitor.Views
+{
+    partial class TestForm
+    {
+        /// <summary>
+        /// Required designer variable.
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary>
+        /// Clean up any resources being used.
+        /// </summary>
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Windows Form Designer generated code
+
+        /// <summary>
+        /// Required method for Designer support - do not modify
+        /// the contents of this method with the code editor.
+        /// </summary>
+        private void InitializeComponent()
+        {
+            this.dataGridView1 = new System.Windows.Forms.DataGridView();
+            ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
+            this.SuspendLayout();
+            // 
+            // dataGridView1
+            // 
+            this.dataGridView1.AllowUserToAddRows = false;
+            this.dataGridView1.AllowUserToDeleteRows = false;
+            this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+            this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.dataGridView1.Location = new System.Drawing.Point(0, 0);
+            this.dataGridView1.Name = "dataGridView1";
+            this.dataGridView1.ReadOnly = true;
+            this.dataGridView1.Size = new System.Drawing.Size(612, 399);
+            this.dataGridView1.TabIndex = 0;
+            // 
+            // TestForm
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(612, 399);
+            this.Controls.Add(this.dataGridView1);
+            this.Name = "TestForm";
+            this.Text = "TestForm";
+            this.Load += new System.EventHandler(this.TestForm_Load);
+            ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
+            this.ResumeLayout(false);
+
+        }
+
+        #endregion
+
+        private System.Windows.Forms.DataGridView dataGridView1;
+    }
+}

+ 19 - 0
Fork.Net/Oreo.NetMonitor/Views/TestForm.cs

@@ -0,0 +1,19 @@
+using System;
+using System.Windows.Forms;
+using Y.Utils.WindowsUtils.InfoUtils;
+
+namespace Oreo.NetMonitor.Views
+{
+    public partial class TestForm : Form
+    {
+        public TestForm()
+        {
+            InitializeComponent();
+        }
+        private void TestForm_Load(object sender, EventArgs e)
+        {
+            var a = NetProcessTool.GetTcpConn();
+            var b = NetProcessTool.GetUdpConn();
+        }
+    }
+}

+ 120 - 0
Fork.Net/Oreo.NetMonitor/Views/TestForm.resx

@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>

+ 1 - 1
Fork.Net/Y.Utils/WindowsUtils/InfoUtils/ScreenCapture.cs

@@ -11,7 +11,7 @@ using System.Text;
 using System.Threading.Tasks;
 using System.Windows.Forms;
 
-namespace Y.Utils.WindowsUtils.InfoUtils
+namespace Y.Utils.IOUtils.ImageUtils
 {
     /// <summary>
     /// 屏幕捕获类

+ 36 - 23
Fork.Net/Y.Utils/WindowsUtils/InfoUtils/SoftwareTool.cs

@@ -18,46 +18,59 @@ namespace Y.Utils.WindowsUtils.InfoUtils
         /// <returns></returns>
         public static bool ExistControl(string name)
         {
-            List<string> list = new List<string>();
+            if (GetControlList().Contains(name))
+                return true;
+            return false;
+        }
+        public static bool ExistControl(string[] names)
+        {
+            bool flag = false;
+            if (!ListTool.IsNullOrEmpty(names))
+            {
+                foreach (var n in names)
+                {
+                    if (ExistControl(n))
+                        return true;
+                }
+            }
+            return flag;
+        }
+        public static List<string> GetControlList()
+        {
+            List<string> result = new List<string>();
+            result.AddRange(GetControlList(Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall")));
+            result.AddRange(GetControlList(Registry.LocalMachine.OpenSubKey("SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall")));
+            result.AddRange(GetControlList(Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall")));
+            result.AddRange(GetControlList(Registry.CurrentUser.OpenSubKey("SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall")));
+            return result;
+        }
+        private static List<string> GetControlList(RegistryKey key)
+        {
+            List<string> result = new List<string>();
             try
             {
-                //打开注册列表卸载选项 SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
-                RegistryKey Key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall");
-                if (Key != null)//如果系统禁止访问则返回null
+                if (key != null)//如果系统禁止访问则返回null
                 {
-                    foreach (String SubKeyName in Key.GetSubKeyNames())
+                    foreach (string SubKeyName in key.GetSubKeyNames())
                     {
                         //打开对应的软件名称
-                        RegistryKey SubKey = Key.OpenSubKey(SubKeyName);
+                        RegistryKey SubKey = key.OpenSubKey(SubKeyName);
                         if (SubKey != null)
                         {
                             String SoftwareName = SubKey.GetValue("DisplayName", "Nothing").ToString();
                             //如果没有取到,则不存入动态数组
                             if (SoftwareName != "Nothing")
                             {
-                                list.Add(SoftwareName.Trim());
+                                result.Add(SoftwareName.Trim());
                             }
                         }
+                        SubKey?.Close();
                     }
                 }
+                key?.Close();
             }
             catch { }
-            if (list.Contains(name))
-                return true;
-            return false;
-        }
-        public static bool ExistControl(string[] names)
-        {
-            bool flag = false;
-            if (!ListTool.IsNullOrEmpty(names))
-            {
-                foreach (var n in names)
-                {
-                    if (ExistControl(n))
-                        return true;
-                }
-            }
-            return flag;
+            return result;
         }
         /// <summary>
         /// 存在进程

+ 195 - 0
Fork.Net/Y.Utils/WindowsUtils/ProcessUtils/NetProcessTool.cs

@@ -0,0 +1,195 @@
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Net;
+using System.Runtime.InteropServices;
+using System.Text;
+
+namespace Y.Utils.WindowsUtils.ProcessUtils
+{
+    public class NetProcessTool
+    {
+        #region 枚举 读取连接表选项
+        enum TCP_TABLE_CLASS
+        {
+            TCP_TABLE_BASIC_LISTENER,
+            TCP_TABLE_BASIC_CONNECTIONS,
+            TCP_TABLE_BASIC_ALL,
+            TCP_TABLE_OWNER_PID_LISTENER,
+            TCP_TABLE_OWNER_PID_CONNECTIONS,
+            TCP_TABLE_OWNER_PID_ALL,
+            TCP_TABLE_OWNER_MODULE_LISTENER,
+            TCP_TABLE_OWNER_MODULE_CONNECTIONS,
+            TCP_TABLE_OWNER_MODULE_ALL
+        }
+        enum UDP_TABLE_CLASS
+        {
+            UDP_TABLE_BASIC,
+            UDP_TABLE_OWNER_PID,
+            UDP_TABLE_OWNER_MODULE
+        }
+        #endregion
+        #region UDP 和 TCP 列表 结构
+        struct UdpTable
+        {
+            public uint dwNumEntries;
+            private UdpRow table;
+        }
+        struct TcpTable
+        {
+            public uint dwNumEntries;
+            private TcpRow table;
+        }
+        #endregion
+        #region UDP 和 TCP 行记录 结构
+        public struct UdpRow
+        {
+            private uint localAddr;
+            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
+            private byte[] localPort;
+
+            public IPAddress LocalIP
+            {
+                get
+                {
+                    return new IPAddress((long)((ulong)this.localAddr));
+                }
+            }
+            public ushort LocalPort
+            {
+                get
+                {
+                    return BitConverter.ToUInt16(new byte[]
+                    {
+                    this.localPort[1],
+                    this.localPort[0]
+                    }, 0);
+                }
+            }
+            public int ProcessId { get; }
+        }
+
+        public struct TcpRow
+        {
+            ConnectionState state;
+            private uint localAddr;
+            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
+            private byte[] localPort;
+            private uint remoteAddr;
+            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
+            private byte[] remotePort;
+
+            public IPAddress LocalIP
+            {
+                get
+                {
+                    return new IPAddress((long)((ulong)this.localAddr));
+                }
+            }
+            public ushort LocalPort
+            {
+                get
+                {
+                    return BitConverter.ToUInt16(new byte[]
+                    {
+                    this.localPort[1],
+                    this.localPort[0]
+                    }, 0);
+                }
+            }
+            public IPAddress RemoteIP
+            {
+                get
+                {
+                    return new IPAddress((long)((ulong)this.remoteAddr));
+                }
+            }
+            public ushort RemotePort
+            {
+                get
+                {
+                    return BitConverter.ToUInt16(new byte[]
+                    {
+                    this.remotePort[1],
+                    this.remotePort[0]
+                    }, 0);
+                }
+            }
+            public int ProcessId { get; }
+        }
+        #endregion
+
+        [DllImport("iphlpapi.dll", SetLastError = true)]
+        static extern uint GetExtendedTcpTable(IntPtr pTcpTable, ref int dwOutBufLen, bool sort, int ipVersion, TCP_TABLE_CLASS tblClass, uint reserved = 0u);
+        [DllImport("iphlpapi.dll", SetLastError = true)]
+        static extern uint GetExtendedUdpTable(IntPtr pUdpTable, ref int dwOutBufLen, bool sort, int ipVersion, UDP_TABLE_CLASS tblClass, uint reserved = 0u);
+
+        public static TcpRow[] GetTcpConn()
+        {
+            TcpRow[] array = null;
+            int ipVersion = 2;
+            int cb = 0;
+            uint extendedTcpTable = GetExtendedTcpTable(IntPtr.Zero, ref cb, true, ipVersion, TCP_TABLE_CLASS.TCP_TABLE_OWNER_PID_ALL, 0u);
+            IntPtr intPtr = Marshal.AllocHGlobal(cb);
+            try
+            {
+                extendedTcpTable = GetExtendedTcpTable(intPtr, ref cb, true, ipVersion, TCP_TABLE_CLASS.TCP_TABLE_OWNER_PID_ALL, 0u);
+                bool flag = extendedTcpTable > 0u;
+                if (flag) return null;
+
+                TcpTable tcpTable = (TcpTable)Marshal.PtrToStructure(intPtr, typeof(TcpTable));
+                IntPtr intPtr2 = (IntPtr)((long)intPtr + Marshal.SizeOf(tcpTable.dwNumEntries));
+                array = new TcpRow[tcpTable.dwNumEntries];
+                int num = 0;
+                while (num < (long)((ulong)tcpTable.dwNumEntries))
+                {
+                    TcpRow tcpRow = (TcpRow)Marshal.PtrToStructure(intPtr2, typeof(TcpRow));
+                    array[num] = tcpRow;
+                    intPtr2 = (IntPtr)((long)intPtr2 + Marshal.SizeOf(tcpRow));
+                    num++;
+                }
+            }
+            catch (Exception)
+            { }
+            finally
+            {
+                Marshal.FreeHGlobal(intPtr);
+            }
+            return array;
+        }
+        public static UdpRow[] GetUdpConn()
+        {
+            UdpRow[] array = null;
+            int ipVersion = 2;
+            int cb = 0;
+            uint extendedUdpTable = GetExtendedUdpTable(IntPtr.Zero, ref cb, true, ipVersion, UDP_TABLE_CLASS.UDP_TABLE_OWNER_PID, 0u);
+            IntPtr intPtr = Marshal.AllocHGlobal(cb);
+            try
+            {
+                extendedUdpTable = GetExtendedUdpTable(intPtr, ref cb, true, ipVersion, UDP_TABLE_CLASS.UDP_TABLE_OWNER_PID, 0u);
+                bool flag = extendedUdpTable > 0u;
+                if (flag) return null;
+
+                UdpTable udpTable = (UdpTable)Marshal.PtrToStructure(intPtr, typeof(UdpTable));
+                IntPtr intPtr2 = (IntPtr)((long)intPtr + Marshal.SizeOf(udpTable.dwNumEntries));
+                array = new UdpRow[udpTable.dwNumEntries];
+                int num = 0;
+                while (num < (long)((ulong)udpTable.dwNumEntries))
+                {
+                    UdpRow udpRow = (UdpRow)Marshal.PtrToStructure(intPtr2, typeof(UdpRow));
+                    array[num] = udpRow;
+                    intPtr2 = (IntPtr)((long)intPtr2 + Marshal.SizeOf(udpRow));
+                    num++;
+                }
+            }
+            catch (Exception)
+            { }
+            finally
+            {
+                Marshal.FreeHGlobal(intPtr);
+            }
+            return array;
+        }
+    }
+}

+ 89 - 0
Fork.Net/Y.Utils/WindowsUtils/ProcessUtils/ProcessInfoTool.cs

@@ -0,0 +1,89 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Drawing;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+
+namespace Y.Utils.WindowsUtils.ProcessUtils
+{
+    public class ProcessInfoTool
+    {
+        #region 程序集信息
+        struct SHFILEINFO
+        {
+            public IntPtr hIcon;
+            public int iIcon;
+            public uint dwAttributes;
+            [MarshalAs(UnmanagedType.LPStr)]
+            public string szDisplayName;
+            [MarshalAs(UnmanagedType.LPStr)]
+            public string szTypeName;
+            public SHFILEINFO(bool b)
+            {
+                this.hIcon = IntPtr.Zero;
+                this.iIcon = 0;
+                this.dwAttributes = 0u;
+                this.szDisplayName = "";
+                this.szTypeName = "";
+            }
+        }
+        enum SHGFI
+        {
+            SmallIcon = 1,
+            LargeIcon = 0,
+            Icon = 256,
+            DisplayName = 512,
+            Typename = 1024,
+            SysIconIndex = 16384,
+            UseFileAttributes = 16
+        }
+        #endregion
+        [DllImport("Shell32.dll")]
+        static extern int SHGetFileInfo(string pszPath, uint dwFileAttributes, out SHFILEINFO psfi, uint cbfileInfo, SHGFI uFlags);
+        static Icon GetIcon(string file, bool small)
+        {
+            SHFILEINFO sHFILEINFO = new SHFILEINFO(true);
+            int cbfileInfo = Marshal.SizeOf(sHFILEINFO);
+            SHGFI uFlags;
+            if (small)
+            {
+                uFlags = (SHGFI)273;
+            }
+            else
+            {
+                uFlags = (SHGFI)272;
+            }
+            SHGetFileInfo(file, 256u, out sHFILEINFO, (uint)cbfileInfo, uFlags);
+            return Icon.FromHandle(sHFILEINFO.hIcon);
+        }
+        public static Icon GetIcon(Process p, bool small)
+        {
+            try
+            {
+                return GetIcon(p.MainModule.FileName, small);
+            }
+            catch (Exception ex) { }
+            return null;
+        }
+        [Obsolete]
+        public static Icon GetIcon(int pid, bool small)
+        {
+            Process processById = Process.GetProcessById(pid);
+            return GetIcon(processById, small);
+        }
+        [Obsolete]
+        public static string GetNameById(int pid)
+        {
+            string result = "";
+            try
+            {
+                Process processById = Process.GetProcessById(pid);
+                result = processById.ProcessName;
+            }
+            catch (Exception ex) { }
+            return result.Trim();
+        }
+    }
+}

+ 1 - 0
Fork.Net/Y.Utils/WindowsUtils/ProcessUtils/ProcessTool.cs

@@ -4,6 +4,7 @@
 //############################################################
 using System;
 using System.Diagnostics;
+using System.Drawing;
 using System.IO;
 using System.Windows.Forms;
 

+ 3 - 1
Fork.Net/Y.Utils/Y.Utils.csproj

@@ -78,6 +78,7 @@
     <Compile Include="AppUtils\PermissionTool.cs" />
     <Compile Include="WindowsUtils\InfoUtils\ComputerInfoTool.cs" />
     <Compile Include="WindowsUtils\InfoUtils\DeviceInfoTool.cs" />
+    <Compile Include="WindowsUtils\ProcessUtils\NetProcessTool.cs" />
     <Compile Include="WindowsUtils\InfoUtils\RegisterTool.cs" />
     <Compile Include="IOUtils\ImageUtils\BarCodeToHTML.cs" />
     <Compile Include="IOUtils\LogUtils\LogLevel.cs" />
@@ -110,10 +111,11 @@
     <Compile Include="IOUtils\TxtUtils\IniTool.cs" />
     <Compile Include="IOUtils\TxtUtils\TxtTool.cs" />
     <Compile Include="DataUtils\DateTimeUtils\UnixTimeTool.cs" />
-    <Compile Include="WindowsUtils\InfoUtils\ScreenCapture.cs" />
+    <Compile Include="IOUtils\ImageUtils\ScreenCapture.cs" />
     <Compile Include="WindowsUtils\InfoUtils\ShortcutTool.cs" />
     <Compile Include="WindowsUtils\InfoUtils\SoftwareTool.cs" />
     <Compile Include="WindowsUtils\InfoUtils\TaskSchedulerTool.cs" />
+    <Compile Include="WindowsUtils\ProcessUtils\ProcessInfoTool.cs" />
     <Compile Include="WindowsUtils\ProcessUtils\ProcessTool.cs" />
   </ItemGroup>
   <ItemGroup>