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

        }
    }

  • 相关阅读:
    Redis学习笔记——环境搭建
    SQL 记录
    路径“D:svn.....”的访问被拒绝问题处理
    去除浏览器自动给input赋值的问题
    获取用户IP
    JS对身份证号码进行验证方法
    JS 实现倒计时
    SQL 游标
    .net上传图片实例
    生成唯一码
  • 原文地址:https://www.cnblogs.com/dengxi/p/7844687.html
Copyright © 2011-2022 走看看