zoukankan      html  css  js  c++  java
  • 取得所有网卡的MAC地址,包括禁用的

    先在nuget包中添加System.Management.Automation引用。

    然后下面就是代码了。

    using System;
    using System.Collections.ObjectModel;
    using System.Management.Automation;
    using System.Text;
    using System.Windows.Forms;

    namespace GetMAC
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }

            private void button1_Click(object sender, EventArgs e)
            {
                StringBuilder sb = new StringBuilder();
                using (PowerShell PowerShellInstance = PowerShell.Create())
                {
                    PowerShellInstance.AddCommand("Get-NetAdapter");

                    Collection<PSObject> PSOutput = PowerShellInstance.Invoke();

                    foreach (PSObject result in PSOutput)
                    {
                        sb.Append(result.Members["PermanentAddress"].Value + " ");
                    }
                }
                textBox1.Text = sb.ToString();
            }

        }
    }

  • 相关阅读:
    [luogu p2482] [SDOI2010]猪国杀
    [luogu p2296] 寻找道路
    左右布局(备用复制)
    导出Excel
    流式布局 及 媒体查询
    echarts设置(持续更新)
    解决Vue中watch首次进入路由不触发的问题
    Math.random
    Vue的拖拽
    使的dialog上下左右居中(弹框居中)
  • 原文地址:https://www.cnblogs.com/dengxi/p/7844687.html
Copyright © 2011-2022 走看看