资源简介
根据获取硬盘序列号和CPU序列号生成机器码,硬盘序列号和CPU序列号全球唯一,所以保证了机器码全球唯一
代码片段和文件信息
/*
* 功 能:获取机器码,实现注册功能,机器码是根据硬盘序列号和CPU序列号生成,硬盘序列号和CPU序列号全球唯一
*
* 时 间:2010/4/21 13:40:12
*
* 程序员:王文壮
*
* Q Q:1020304029
*
* 邮 箱:WangWenzhuang_net@163.com
*
* 博 客:http://blog.csdn.net/wangwenzhuang
*/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Management;
using System.Security.Cryptography;
namespace GetMachineCode
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void buttonGetHardDiskID_Click(object sender EventArgs e)
{
textBoxHardDiskID.Text = GetHardDiskID();
}
private void buttonGetCPUID_Click(object sender EventArgs e)
{
textBoxCPUID.Text = GetCPUID();
}
private void buttonRandomMachineCode_Click(object sender EventArgs e)
{
textBoxMachineCode.Text = GetSHA1MachineCode(textBoxHardDiskID.Text + textBoxCPUID.Text);
}
///获取磁盘序列号
///
/// 获取磁盘序列号
///
private string GetHardDiskID()
{
string hardDiskId = string.Empty;
try
{
ManagementobjectSearcher cmicWmi = new ManagementobjectSearcher(“SELECT * FROM Win32_DiskDrive“);
UInt32 tmpUint32 = 0;
foreach (Managementobject cmicWmiObj in cmicWmi.Get())
{
tmpUint32 = Convert.ToUInt32(cmicWmiObj[“signature“].ToString());
}
hardDiskId = tmpUint32.ToString();
}
catch { }
return hardDiskId;
}
///获取cpu序列号
///
/// 获取cpu序列号
///
private string GetCPUID()
{
string cpuId = string.Empty;
try
{
ManagementobjectSearcher Wmi = new ManagementobjectSearcher(“SELECT * FROM Win32_Processor“);
foreach (Managementobject WmiObj in Wmi.Get())
{
cpuId = WmiObj[“ProcessorId“].ToString();
}
}
catch { }
return cpuId;
}
///获取经过SHA1哈希之后的机器码
///
/// 获取经过SHA1哈希之后的机器码
///
private string GetSHA1MachineCode(string code)
{
byte[] buffer = Encoding.ASCII.GetBytes(code);
SHA1 sha1 = SHA1.Create();
return BitConverter.ToString(sha1.ComputeHash(buffer)).Replace(“-“ ““);
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 11264 2010-04-21 13:39 GetMachineCode\GetMachineCode\bin\Debug\GetMachineCode.exe
文件 26112 2010-04-21 13:39 GetMachineCode\GetMachineCode\bin\Debug\GetMachineCode.pdb
文件 14328 2010-04-21 13:05 GetMachineCode\GetMachineCode\bin\Debug\GetMachineCode.vshost.exe
文件 490 2009-06-11 05:14 GetMachineCode\GetMachineCode\bin\Debug\GetMachineCode.vshost.exe.manifest
文件 22232 2005-10-14 02:45 GetMachineCode\GetMachineCode\bin\Debug\msmdvbanet.dll
文件 2972 2010-04-21 13:40 GetMachineCode\GetMachineCode\Form1.cs
文件 6893 2010-04-21 13:39 GetMachineCode\GetMachineCode\Form1.Designer.cs
文件 5814 2010-04-21 13:39 GetMachineCode\GetMachineCode\Form1.resx
文件 3869 2010-04-21 13:05 GetMachineCode\GetMachineCode\GetMachineCode.csproj
文件 712 2010-04-21 13:34 GetMachineCode\GetMachineCode\obj\Debug\GetMachineCode.csproj.FileListAbsolute.txt
文件 847 2010-04-21 13:39 GetMachineCode\GetMachineCode\obj\Debug\GetMachineCode.csproj.GenerateResource.Cache
文件 11264 2010-04-21 13:39 GetMachineCode\GetMachineCode\obj\Debug\GetMachineCode.exe
文件 180 2010-04-21 13:39 GetMachineCode\GetMachineCode\obj\Debug\GetMachineCode.Form1.resources
文件 26112 2010-04-21 13:39 GetMachineCode\GetMachineCode\obj\Debug\GetMachineCode.pdb
文件 180 2010-04-21 13:05 GetMachineCode\GetMachineCode\obj\Debug\GetMachineCode.Properties.Resources.resources
文件 8224 2010-04-21 13:04 GetMachineCode\GetMachineCode\obj\Debug\ResolveAssemblyReference.cache
文件 475 2010-04-21 13:05 GetMachineCode\GetMachineCode\Program.cs
文件 1360 2010-04-21 13:01 GetMachineCode\GetMachineCode\Properties\AssemblyInfo.cs
文件 2878 2010-04-21 13:01 GetMachineCode\GetMachineCode\Properties\Resources.Designer.cs
文件 5612 2010-04-21 13:01 GetMachineCode\GetMachineCode\Properties\Resources.resx
文件 1099 2010-04-21 13:01 GetMachineCode\GetMachineCode\Properties\Settings.Designer.cs
文件 249 2010-04-21 13:01 GetMachineCode\GetMachineCode\Properties\Settings.settings
文件 932 2010-04-21 13:02 GetMachineCode\GetMachineCode.sln
..A..H. 13312 2010-04-21 13:40 GetMachineCode\GetMachineCode.suo
目录 0 2010-04-21 13:15 GetMachineCode\GetMachineCode\obj\Debug\Refactor
目录 0 2010-04-21 13:02 GetMachineCode\GetMachineCode\obj\Debug\TempPE
目录 0 2010-04-21 13:07 GetMachineCode\GetMachineCode\bin\Debug
目录 0 2010-04-21 13:39 GetMachineCode\GetMachineCode\obj\Debug
目录 0 2010-04-21 13:01 GetMachineCode\GetMachineCode\bin
目录 0 2010-04-21 13:01 GetMachineCode\GetMachineCode\obj
............此处省略6个文件信息
- 上一篇:C#+SQLServer2000学生管理系统源代码
- 下一篇:unrate.csv
相关资源
- C# TIP文件生成和拆解
- C#解析HL7消息的库135797
- C# OCR数字识别实例,采用TessnetOcr,对
- 考试管理系统 - C#源码
- asp.net C#购物车源代码
- C#实时网络流量监听源码
- C#百度地图源码
- Visual C#.2010从入门到精通配套源程序
- C# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
- C#版保龄球记分代码
川公网安备 51152502000135号
评论
共有 条评论