zoukankan      html  css  js  c++  java
  • C#得到CPU的序列号、硬盘序列号、网卡序列号

    //得到cpu信息
    public static void GetCpuIndex()
     {
                string _cpuInfo = "";
                ManagementClass cimobject = new ManagementClass("Win32_Processor");
                ManagementObjectCollection moc = cimobject.GetInstances();
                foreach (ManagementObject mo in moc)
                {
                    _cpuInfo = mo.Properties["ProcessorId"].Value.ToString();
                }
                return _cpuInfo;
    }

    // 得到硬盘序列号

    public static void GetHDIndex()
     {
                string _HDInfo = "";
                ManagementClass cimobject1 = new ManagementClass("Win32_DiskDrive");
                ManagementObjectCollection moc1 = cimobject1.GetInstances();
                foreach (ManagementObject mo in moc1)
                {
                    _HDInfo = (string)mo.Properties["Model"].Value;


                }
                retrun _HDInfo;
    }

    //获取网卡硬件地址
     public static void GetMacAddress()
     {
                string _MacAddress = "";
                ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
                ManagementObjectCollection moc2 = mc.GetInstances();
                foreach (ManagementObject mo in moc2)
                {
                    if ((bool)mo["IPEnabled"] == true)
                        MacAddress = mo["MacAddress"].ToString();
                    mo.Dispose();
                }
               
                return _MacAddress;
     }

  • 相关阅读:
    C++输入cout与输出cin
    golang学习笔记
    vscode环境配置
    golang 微框架 gin
    git go使用socket5代理
    go包管理工具glide
    collectd的python插件(redis)
    zookeeper & kafka 集群
    redis复制集(sentinel)
    python加解密
  • 原文地址:https://www.cnblogs.com/zhangtao/p/1972397.html
Copyright © 2011-2022 走看看