cpu编号和硬盘编号 在网吧,这两项所有的电脑取出来都是一摸一样的.
网卡MAC地址,这个地址是可以通过注册表修改的,并且重装系统等情况就会改变.
该怎么获取唯一不变的机器码?是否有其他好的方法?
cpu编号和硬盘编号, 这两个怎么可能是一样的, 理论上全球唯一的
就是同时装的机器,cpu编号和硬盘编号就是一样的。
验证这个,编码的确不好弄。
不过简单一些就用这两个也可以。不知道楼主做的东西是什么。
楼主用加密狗不。硬件加密就可以。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Management;
using System.Security.Cryptography;
/// <summary>
/// 读取CPU机器码
/// </summary>
/// <returns></returns>
public static string Get_Cpu_Id()
{
string cpuInfo = " ";
using (ManagementClass cimobject = new ManagementClass("Win32_Processor"))
{
ManagementObjectCollection moc = cimobject.GetInstances();
foreach (ManagementObject mo in moc)
{
cpuInfo = mo.Properties["ProcessorId"].Value.ToString();
mo.Dispose();
}
}
return cpuInfo.ToString();
}
/// <summary>
/// 读取硬盘机器码
/// </summary>
/// <returns></returns>
public static string Get_HardDisk_Id()
{
string HDid = " ";
using (ManagementClass cimobject1 = new ManagementClass("Win32_DiskDrive"))
{
ManagementObjectCollection moc1 = cimobject1.GetInstances();
foreach (ManagementObject mo in moc1)
{
HDid = (string)mo.Properties["Model"].Value;
mo.Dispose();
}
}
return HDid.ToString();
}
/// <summary>
/// 读取网卡机器码
/// </summary>
/// <returns></returns>
public static string Get_NetworkCard_Id()
{
string MoAddress = " ";
using (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();
}