• 主机信息


    #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

  • 相关阅读:
    iOS中使用nil NULL NSNULL的区别
    Xcode常用快捷键总结
    (求租仓库)navigationController .navigationBar 的属性设置
    imageNamed 与 initWithContentsOfFile 区别
    iOS-Senior10-多线程(子线程创建)
    iOS-setValue和setObject的区别
    iOS-Senior8-网络之进阶
    iOS-Senior7-数据请求
    iOS-Senior6-数据解析(JSON)
    iOS-Senior6-数据解析(XML)
  • 原文地址:https://www.cnblogs.com/bingyun84/p/1688804.html
Copyright © 2020-2023  润新知