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();
            }

        }
    }

  • 相关阅读:
    mysql授权
    mysql函数大全
    mysql常用命令
    ECMAScript中变量的解构赋值
    ECMAScript中的const常量
    ECMAScript中let与var的区别
    javaScript中的变量作用域的闭包处理
    javaScript的prototype对象
    javaScript中的this作用域
    js对象的创建方式
  • 原文地址:https://www.cnblogs.com/dengxi/p/7844687.html
Copyright © 2011-2022 走看看