zoukankan      html  css  js  c++  java
  • 主机信息

    #region 获得主机相关信息 // 得到主板序列号
            private string GetMotherBoardSerialNumber()
            {
               
    string SerialNumber = "";
                ManagementClass mc
    = new ManagementClass("WIN32_BaseBoard");
                ManagementObjectCollection moc
    = mc.GetInstances();
               
    foreach (ManagementObject mo in moc)
                {
                    SerialNumber
    = mo["SerialNumber"].ToString();
                   
    break;
                }
               
    return SerialNumber.Replace(" ","");
            }

           
    // 得到CPU序列号
            private string GetMotherProcessorNumber()
            {
               
    string CPUCode = "";
                ManagementClass mcCpu
    = new ManagementClass("win32_Processor");
                ManagementObjectCollection mocCpu
    = mcCpu.GetInstances();
               
    foreach(ManagementObject m in mocCpu)
                {
                    CPUCode
    = m["ProcessorId"].ToString();
                }
               
    return CPUCode.Replace(" ", "");
            }

           
    // 得到硬盘序列号
            private string GetMotherLogicaldiskNumber()
            {
               
    string logicaldiskcode = "";
                ManagementClass mcHD
    = new ManagementClass("win32_logicaldisk");
                ManagementObjectCollection mocHD
    = mcHD.GetInstances();
               
    foreach (ManagementObject m in mocHD)
                {
                   
    if (m["DeviceID"].ToString() == "C:")
                    {
                        logicaldiskcode
    = m["VolumeSerialNumber"].ToString();
                       
    break;
                    }
                }
               
    return logicaldiskcode.Replace(" ", "");
            }

           
    // 得到网卡MAC地址
            private string GetNetworkAdapterConfiguration()
            {
               
    string NetworkAdapterConfiguration = "";
                ManagementClass mcMAC
    = new ManagementClass("Win32_NetworkAdapterConfiguration");
                ManagementObjectCollection mocMAC
    = mcMAC.GetInstances();
               
    foreach(ManagementObject m in mocMAC)
                {
                   
    if((bool)m["IPEnabled"])
                    {
                        NetworkAdapterConfiguration
    = m["MacAddress"].ToString();
                       
    break;
                    }
                }
               
    return NetworkAdapterConfiguration;
            }

           
    #endregion

  • 相关阅读:
    一些关于HDFS的基本知识
    WordPress使用子主题继承和修改主题
    IQueryable、IQueryProvider接口详解
    FM并发编程练习:改写苏飞的C#多线程网站压力测试程序
    利用Webkit抓取动态网页和链接
    HTTP协议之代理
    PortalBasic Java Web 应用开发框架 v3.0.1 即将发布
    算法导论1.排序算法
    CSS题目 子元素决定父元素的大小
    使用solrj和EasyNet.Solr进行原子更新
  • 原文地址:https://www.cnblogs.com/bingyun84/p/1688804.html
Copyright © 2011-2022 走看看