• 大小: 0.21M
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2024-05-03
  • 语言: C#
  • 标签: 信息  网卡  获取  IP  

资源简介


资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Management;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Text;
using System.Text.Regularexpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace IP
{
    public partial class IP变更工具 : Form
    {
           
        List networkAdapter = new List();

        public IP变更工具()
        {
            InitializeComponent();
        }




        /// 
        /// 获取所有适配器类型,适配器被禁用则不能获取到
        /// 

        /// 
        public void GetAllNetworkAdapters() //如果适配器被禁用则不能获取到
        {

            NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();
            foreach (NetworkInterface adapter in adapters)
            {
                if (adapter.OperationalStatus.ToString() == “Up“)
                {
                    if (adapter.NetworkInterfaceType == NetworkInterfaceType.Ethernet || adapter.NetworkInterfaceType == NetworkInterfaceType.Wireless80211)
                    {
                        if (adapter.Name.ToString().Contains(“VMware“) == false)
                      {
                            IPInterfaceProperties ips = adapter.GetIPProperties();
                            string description = adapter.Name;//描述
                            string networkInterfaceType = adapter.NetworkInterfaceType.ToString();
                            string speed = adapter.Speed / 1000 / 1000 + “MB“;
                            PhysicalAddress macAddress = adapter.GetPhysicalAddress(); //物理地址集合
                            string networkInterfaceID = adapter.Id;//网络适配器标识符
                            GatewayIPAddressInformationCollection getwaryes = ips.GatewayAddresses; //网关地址集合
                            UnicastIPAddressInformationCollection ipAddresses = ips.UnicastAddresses; //IP地址集合
                           
                            IPAddressCollection dhcpServerAddresses = ips.DhcpServerAddresses;//DHCP地址集合
                            bool IsDhcpEnabled = ips.GetIPv4Properties() == null ? false : ips.GetIPv4Properties().IsDhcpEnabled; //是否启用DHCP服务
                            IPInterfaceProperties adapterProperties = adapter.GetIPProperties();//获取IPInterfaceProperties实例  
                            IPAddressCollection dnsAddresses = adapterProperties.DnsAddresses;
                            comboBox1.Items.Add(description);


                           // MessageBox.Show(adapter.OperationalStatus.ToString());
                            networkAdapter.Add(new NetworkAdapter(description networkInterfaceType speed macAddress networkInterfaceID getwaryes ipAddresses dhcpServerAddresses IsDhcpEnabled dnsAddresses));

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2020-10-26 19:27  .vs\
     目录           0  2020-10-26 19:27  .vs\IP\
     目录           0  2020-10-26 19:27  .vs\IP\v16\
     文件       46592  2020-10-30 14:58  .vs\IP\v16\.suo
     目录           0  2020-10-26 19:27  .vs\IP\v16\Server\
     目录           0  2020-10-26 19:27  .vs\IP\v16\Server\sqlite3\
     文件           0  2020-01-27 16:45  .vs\IP\v16\Server\sqlite3\db.lock
     文件      606208  2020-02-26 17:26  .vs\IP\v16\Server\sqlite3\storage.ide
     文件        1111  2020-01-27 16:44  IP.sln
     目录           0  2020-10-26 19:27  IP\
     文件         187  2020-01-27 16:44  IP\App.config
     目录           0  2020-10-26 19:27  IP\bin\
     目录           0  2020-10-26 19:27  IP\bin\Debug\
     文件       23552  2020-10-30 14:57  IP\bin\Debug\IP.exe
     文件         187  2020-01-27 16:44  IP\bin\Debug\IP.exe.config
     文件       52736  2020-10-30 14:57  IP\bin\Debug\IP.pdb
     目录           0  2020-01-27 21:12  IP\bin\Release\
     文件       14007  2020-05-07 14:57  IP\Form1.cs
     文件       13736  2020-01-30 23:30  IP\Form1.Designer.cs
     文件        5817  2020-01-30 23:30  IP\Form1.resx
     文件        4037  2020-01-30 19:28  IP\IP.csproj
     文件        1819  2020-01-30 20:27  IP\net.cs
     目录           0  2020-10-26 19:27  IP\obj\
     目录           0  2020-10-30 14:58  IP\obj\Debug\
     文件         523  2020-01-28 18:07  IP\Program.cs
     目录           0  2020-10-26 19:27  IP\Properties\
     文件        3301  2020-01-28 12:29  IP\Properties\app.manifest
     文件        1296  2020-01-27 16:44  IP\Properties\AssemblyInfo.cs
     文件        2817  2020-01-27 16:44  IP\Properties\Resources.Designer.cs
     文件        5612  2020-01-27 16:44  IP\Properties\Resources.resx
     文件        1089  2020-01-27 16:44  IP\Properties\Settings.Designer.cs
............此处省略2个文件信息

评论

共有 条评论