using System;
using System.Management;
using System.IO;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;
using Microsoft.Win32;
namespace rocket
{
public class SoftKey硬盘序列号查询
{
#region 获取cpu序列号 硬盘ID 网卡硬地址
#获取cpu序列号
public static 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
public static 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();
}
#获取网卡硬件地址
public static 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();
}
#region 获取网卡硬地址+CPU序列号+硬盘ID字符串
# 获取网卡硬地址+CPU序列号+硬盘ID字符串
public static string GetAll()
{
return GetMoAddress() + GetCpuInfo() + GetHDid();
}
}
}
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论