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

  • 相关阅读:
    搜狗输入法体验评价
    找水王
    onActivityResult方法中返回码resultCode始终为RESULT_CANCEL(0)的问题排查
    win10平台Android平台签名证书(.keystore)生成出现乱码问题
    Toolbar融入状态栏实现沉浸式遇到的问题
    使用MuMu模拟器调试AndroidStudio项目
    解决Android Studio在同步sync时各种can't resolve *** 问题
    Android Studio解决新建项目时support:appcompat问题
    使用ActivityLifecycleCallbacks对活动监听和管理
    butterknife的使用
  • 原文地址:https://www.cnblogs.com/bingyun84/p/1688804.html
Copyright © 2011-2022 走看看