资源简介

根据电脑硬件信息生成唯一的序列号,不依赖于任何第三方组件,包括:硬盘的卷标号、硬盘ID、CPU的序列号、网卡硬件地址、IP地址、登录用户名、计算机名、PC类型、物理内存。

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Management;

namespace Com.Netframe.Computer.Handware
{
    public class HardwareInfo
    {
        /// 
        /// 取得设备硬盘的卷标号
        /// 

        /// 
        public string GetDiskVolumeSerialNumber()
        {
            try
            {
                ManagementClass mc = new ManagementClass(“Win32_NetworkAdapterConfiguration“);
                Managementobject disk = new Managementobject(“win32_logicaldisk.deviceid=\“c:\““);
                disk.Get();
                return disk.GetPropertyValue(“VolumeSerialNumber“).ToString();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// 
        /// 获取硬盘ID 
        /// 

        /// 
        public string GetDiskID()
        {
            try
            {
                String HDid = ““;
                ManagementClass mc = new ManagementClass(“Win32_DiskDrive“);
                ManagementobjectCollection moc = mc.GetInstances();
                foreach (Managementobject mo in moc)
                {
                    HDid = (string)mo.Properties[“Model“].Value;
                }
                moc = null;
                mc = null;
                return HDid;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// 
        /// 获得CPU的序列号
        /// 

        /// 
        public string GetCpuID()
        {
            try
            {
                string cpuInfo = ““;//cpu序列号 
                ManagementClass mc = new ManagementClass(“Win32_Processor“);
                ManagementobjectCollection moc = mc.GetInstances();
                foreach (Managementobject mo in moc)
                {
                    cpuInfo = mo.Properties[“ProcessorId“].Value.ToString();
                    break;
                }
                moc = null;
                mc = null;
                return cpuInfo;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// 
        /// 获取网卡硬件地址 
        /// 

        /// 
        public string GetMacAddress()
        {
            try
            {
                string mac = ““;
                ManagementClass mc = new ManagementClass(“Win32_NetworkAdapterConfiguration“);
                ManagementobjectCollection moc = mc.GetInstances();
                foreach (Managementobject mo in moc)
                {
                    if ((bool)mo[“IPEnabled“] == true)
                    {
                        mac = mo[“MacAddress“].ToString();
                        break;
            

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2016-09-24 14:26  LicenseGenerator\
     目录           0  2016-09-24 14:26  LicenseGenerator\ComputerHandware\
     目录           0  2016-09-24 14:26  LicenseGenerator\ComputerHandware\bin\
     目录           0  2016-09-24 14:26  LicenseGenerator\ComputerHandware\bin\Debug\
     文件        7680  2018-05-08 17:22  LicenseGenerator\ComputerHandware\bin\Debug\ComputerHandware.dll
     文件       22016  2018-05-08 17:22  LicenseGenerator\ComputerHandware\bin\Debug\ComputerHandware.pdb
     目录           0  2016-09-10 14:07  LicenseGenerator\ComputerHandware\bin\Release\
     文件        2487  2016-09-10 14:45  LicenseGenerator\ComputerHandware\ComputerHandware.csproj
     文件        9475  2016-09-10 15:12  LicenseGenerator\ComputerHandware\HardwareInfo.cs
     目录           0  2016-09-24 14:26  LicenseGenerator\ComputerHandware\obj\
     目录           0  2018-05-08 17:22  LicenseGenerator\ComputerHandware\obj\Debug\
     文件         946  2018-05-08 17:22  LicenseGenerator\ComputerHandware\obj\Debug\ComputerHandware.csproj.FileListAbsolute.txt
     文件        1905  2018-05-08 17:22  LicenseGenerator\ComputerHandware\obj\Debug\ComputerHandware.csprojResolveAssemblyReference.cache
     文件        7680  2018-05-08 17:22  LicenseGenerator\ComputerHandware\obj\Debug\ComputerHandware.dll
     文件       22016  2018-05-08 17:22  LicenseGenerator\ComputerHandware\obj\Debug\ComputerHandware.pdb
     文件        6635  2017-12-01 10:05  LicenseGenerator\ComputerHandware\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
     文件           0  2016-09-10 14:06  LicenseGenerator\ComputerHandware\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
     文件           0  2016-09-10 14:06  LicenseGenerator\ComputerHandware\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
     文件           0  2016-09-10 14:06  LicenseGenerator\ComputerHandware\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
     目录           0  2016-09-10 14:06  LicenseGenerator\ComputerHandware\obj\Debug\TempPE\
     目录           0  2016-09-24 14:26  LicenseGenerator\ComputerHandware\Properties\
     文件        1352  2016-09-10 14:06  LicenseGenerator\ComputerHandware\Properties\AssemblyInfo.cs
     目录           0  2016-09-24 14:26  LicenseGenerator\LicenseGenerator\
     文件        2420  2016-09-10 14:58  LicenseGenerator\LicenseGenerator.sln
     文件       83968  2018-05-08 17:26  LicenseGenerator\LicenseGenerator.v11.suo
     文件         187  2016-09-10 13:35  LicenseGenerator\LicenseGenerator\App.config
     目录           0  2016-09-24 14:26  LicenseGenerator\LicenseGenerator\bin\
     目录           0  2018-05-08 17:22  LicenseGenerator\LicenseGenerator\bin\Debug\
     文件        7680  2018-05-08 17:22  LicenseGenerator\LicenseGenerator\bin\Debug\ComputerHandware.dll
     文件       22016  2018-05-08 17:22  LicenseGenerator\LicenseGenerator\bin\Debug\ComputerHandware.pdb
     文件         187  2016-09-10 13:35  LicenseGenerator\LicenseGenerator\bin\Debug\LicenseGenerator.exe.config
............此处省略68个文件信息

评论

共有 条评论