• C# 获取计算机 信息


            /// <summary>  
            /// 获取本机 机器名   
            /// </summary>  
            /// <returns></returns>  
            public static string GetMachineName()
              {        
                           return Environment.GetEnvironmentVariable("COMPUTERNAME");
               }   
            /// <summary>  
            /// 获取本机的MAC地址  
            /// </summary>  
            /// <returns></returns>  
            public static string GetLocalMac()
            {
                string mac = null;
                ManagementObjectSearcher query = new ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapterConfiguration");
                ManagementObjectCollection queryCollection = query.Get();
                foreach (ManagementObject mo in queryCollection)
                {
                    if (mo["IPEnabled"].ToString() == "True")
                        mac = mo["MacAddress"].ToString();
                }
                return (mac);
            }  
            /// <summary>
            /// 取得设备硬盘的卷标号
            /// </summary>
            /// <returns></returns>
            public string GetDiskVolumeSerialNumber()
            {
                ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
                ManagementObject disk = new ManagementObject("win32_logicaldisk.deviceid="c:"");
                disk.Get();
                return disk.GetPropertyValue("VolumeSerialNumber").ToString();
            }
            /// <summary>
            /// 获得CPU的序列号
            /// </summary>
            /// <returns></returns>
            public string getCpu()
            {
                string strCpu = null;
                ManagementClass myCpu = new ManagementClass("win32_Processor");
                ManagementObjectCollection myCpuConnection = myCpu.GetInstances();
                foreach (ManagementObject myObject in myCpuConnection)
                {
                    strCpu = myObject.Properties["Processorid"].Value.ToString();
                    break;
                }
                return strCpu;
            }
  • 相关阅读:
    STM32F746G-DISCO官方例程烧写
    zedboard学习第一篇
    itop4412开发板添加开机启动程序
    dsp6657的串口学习
    开源SLAM
    非线性滤波(信号处理)
    图形学领域的关键算法及源码链接
    基于倾斜影像的城市三维场景重建
    基于RFID恢复信号场
    对“自然语言处理”的理解
  • 原文地址:https://www.cnblogs.com/su-king/p/5122036.html
Copyright © 2020-2023  润新知