• 获取CPU编号和MAC地址


    首先要引用 System.Management.dll

    //取CPU编号
         public string GetCpuID()
          {
              try
              {
                  ManagementClass mc = new ManagementClass("Win32_Processor");
                  ManagementObjectCollection moc = mc.GetInstances();
      
                  string strCpuID = null;
                 foreach (ManagementObject mo in moc)
                 {
                     strCpuID = mo.Properties["ProcessorId"].Value.ToString();
                     break;
                 }
                 return strCpuID;
             }
             catch
             {
                 return "";
             }

         }

         //获取网卡mac地址
         public string GetMac()
         {
             try
             {
                 ManagementObjectSearcher query = new ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapterConfiguration");
                 ManagementObjectCollection queryCollection = query.Get();
                 foreach (ManagementObject mo in queryCollection)
                 {
                     if (mo["IPEnabled"].ToString() == "True")
                         return mo["MacAddress"].ToString();
                 }
                 return "";
             }
             catch
             {
                 return "";
             }
         }

  • 相关阅读:
    nginx proxy_set_header
    nginx minio
    /etc/nginx/sitesenabled
    IDEA从mapper.java或者dao.java跳转到mapper.xml
    htmlwebpackplugin 配置项
    第29天 [js]时间戳转换
    CSS权重值计算
    nginx+keepalived实现高可用负载均衡 繁华
    kali安装 IDEA2020 破解并创建快捷方式
    下载 android source 之repo获取
  • 原文地址:https://www.cnblogs.com/zzxap/p/2175913.html
Copyright © 2020-2023  润新知