资源简介

winform实时获取网卡网速全部源码,获取电脑上传下载速度(.NET2.0 vs2013)

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;

namespace NetMonitor
{
    public partial class NetMonitor : Form
    {
        [DllImport(“User32.DLL“)]
        public static extern int SendMessage(IntPtr hWnd uint Msg int wParam int lParam);
        [DllImport(“User32.DLL“)]
        public static extern bool ReleaseCapture();
        public const uint WM_SYSCOMMAND = 0x0112;
        public const int SC_MOVE = 61456;
        public const int HTCAPTION = 2;

        private NetworkMonitor Monitor;
        public NetMonitor()
        {
            InitializeComponent();
            contextMenuStrip1.Visible = false;
            InitAdapterItems();
        }

        private void InitAdapterItems()
        {
            Monitor = new NetworkMonitor();
            int i = 0;
            foreach (var adapter in Monitor.Adapters)
            {
                ToolStripMenuItem adapterMenuItem = new ToolStripMenuItem(adapter.Name);
                adapterMenuItem.Name = adapter.Name;
                adapterMenuItem.Tag = i++;
                adapterMenuItem.Click += new System.EventHandler(this.adapterToolStripMenuItem_Click);
                selectAdapterToolStripMenuItem.DropDownItems.Add(adapterMenuItem);
            }
            Monitor.StartMonitoring();
        }

        private void adapterToolStripMenuItem_Click(object sender EventArgs e)
        {
            Monitor.StopMonitoring();
            var item = sender as ToolStripMenuItem;
            if (item.Tag == null)
            {
                Monitor.StartMonitoring();
            }
            else
            {
                Monitor.StartMonitoring(new NetworkAdapter[]{ Monitor.Adapters[(int) item.Tag]});
            }
            foreach (ToolStripMenuItem toolItem in selectAdapterToolStripMenuItem.DropDownItems)
            {
                if (toolItem == item)
                {
                    toolItem.Text = “√“ + toolItem.Name;
                }
                else
                {
                    toolItem.Text = toolItem.Name;
                }
            }
        }

        private void NetMonitor_MouseUp(object sender MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                contextMenuStrip1.Show(Cursor.Position);
                contextMenuStrip1.Visible = true;
            }
        }

        private void exitToolStripMenuItem_Click(object sender EventArgs e)
        {
            Application.Exit();
        }

        private void NetMonitor_Leave(object sender EventArgs e)
        {
            contextMenuStrip1.Visible = false;
        }

        private void NetMonitor_MouseDown(object sender MouseEventArgs e)
        {
            ReleaseCapture();
            SendMessage(Handle WM_SYSCOMMAND SC_MOVE | HTCAPTION 0);
        }

        priva

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2020-12-01 10:58  NetMonitor\
     文件         157  2020-12-01 10:58  NetMonitor\App.config
     目录           0  2020-12-01 10:36  NetMonitor\bin\
     目录           0  2020-12-01 10:59  NetMonitor\bin\Debug\
     文件      518144  2020-12-01 10:59  NetMonitor\bin\Debug\NetMonitor.exe
     文件         157  2020-12-01 10:58  NetMonitor\bin\Debug\NetMonitor.exe.config
     文件       36352  2020-12-01 10:59  NetMonitor\bin\Debug\NetMonitor.pdb
     文件       22704  2020-12-01 10:59  NetMonitor\bin\Debug\NetMonitor.vshost.exe
     文件         157  2020-12-01 10:58  NetMonitor\bin\Debug\NetMonitor.vshost.exe.config
     文件        3337  2018-12-30 15:29  NetMonitor\bin\Debug\NetMonitor.vshost.exe.manifest
     目录           0  2020-12-01 10:58  NetMonitor\bin\Debug\zh-Hans\
     文件      103019  2018-12-30 15:29  NetMonitor\favicon.ico
     文件        3743  2020-12-01 10:58  NetMonitor\Form1.cs
     文件        8879  2018-12-30 15:29  NetMonitor\Form1.Designer.cs
     文件      159196  2018-12-30 15:29  NetMonitor\Form1.resx
     文件        6357  2020-12-01 10:59  NetMonitor\NetMonitor.csproj
     文件        3456  2020-12-01 10:49  NetMonitor\NetworkAdapter.cs
     文件        7607  2020-12-01 10:58  NetMonitor\NetworkMonitor.cs
     目录           0  2020-12-01 10:36  NetMonitor\obj\
     目录           0  2020-12-01 11:00  NetMonitor\obj\Debug\
     文件         791  2020-12-01 11:00  NetMonitor\obj\Debug\DesignTimeResolveAssemblyReferences.cache
     文件        6553  2020-12-01 10:59  NetMonitor\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
     文件         813  2020-12-01 11:00  NetMonitor\obj\Debug\NetMonitor.csproj.FileListAbsolute.txt
     文件         924  2020-12-01 10:59  NetMonitor\obj\Debug\NetMonitor.csproj.GenerateResource.Cache
     文件      518144  2020-12-01 10:59  NetMonitor\obj\Debug\NetMonitor.exe
     文件      103585  2020-12-01 10:59  NetMonitor\obj\Debug\NetMonitor.NetMonitor.resources
     文件       36352  2020-12-01 10:59  NetMonitor\obj\Debug\NetMonitor.pdb
     文件      291375  2020-12-01 10:59  NetMonitor\obj\Debug\NetMonitor.Properties.Resources.resources
     文件           0  2020-12-01 10:36  NetMonitor\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
     文件           0  2020-12-01 10:36  NetMonitor\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
     文件           0  2020-12-01 10:36  NetMonitor\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
............此处省略14个文件信息

评论

共有 条评论