首页 .NET/Web ASp.NET 获取CUP序列号,硬盘ID,网卡地址

ASp.NET 获取CUP序列号,硬盘ID,网卡地址

作者:胡同里的砖头 围观群众:1665 更新于:2013-12-19

命名空间:

using System.Management;
using System.IO;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;
using Microsoft.Win32;

/// <summary>
    /// CPU序列号
    /// </summary>
    /// <returns></returns>
        public string GetCpuInfo()
        {
            string cpuInfo = " ";
            ManagementClass cimobject = new ManagementClass("Win32_Processor");
            ManagementObjectCollection moc = cimobject.GetInstances();
            foreach (ManagementObject mo in moc)
            {
                cpuInfo = mo.Properties["ProcessorId"].Value.ToString();
            }
            return cpuInfo.ToString();
        }
        ///  
        ///   获取硬盘ID    
        ///  
        ///   string
        public string GetHDid()
        {
            string HDid = " ";
            ManagementClass cimobject1 = new ManagementClass("Win32_DiskDrive");
            ManagementObjectCollection moc1 = cimobject1.GetInstances();
            foreach (ManagementObject mo in moc1)
            {
                HDid = (string)mo.Properties["Model"].Value;
            }
            return HDid.ToString();
        }

        ///  
        ///   获取网卡硬件地址
        ///  
        ///   string
        public string GetMoAddress()
        {
            string MoAddress = " ";
            ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
            ManagementObjectCollection moc2 = mc.GetInstances();
            foreach (ManagementObject mo in moc2)
            {
                if ((bool)mo["IPEnabled"] == true)
                    MoAddress = mo["MacAddress"].ToString();
                mo.Dispose();
            }
            return MoAddress.ToString();
        }

  • 本文标题: ASp.NET 获取CUP序列号,硬盘ID,网卡地址
  • 文章分类:【.NET/Web】
  • 非特殊说明,本文版权归【胡同里的砖头】个人博客 所有,转载请注明出处.
留言评论
站点声明:
1、本站【胡同里的砖头】个人博客,借鉴网上一些博客模板,取其各优点模块自行拼装开发,本博客开发纯属个人爱好。
2、所有笔记提供给广大用户交流使用,可转载,可复制,纯个人开发所遇问题锦集记录使用
Copyright © huzlblog.com All Rights Reserved. 备案号:苏ICP备2021056683号-8