C#生成软件注册码
开发软件时,当用到商业用途时,注册码与激活码就显得很重要了。现在的软件破解技术实在在强了,各种国内外大型软件都有注册机制,但同时也不断地被破解。下面发的只是一个常用版本,发出源码被破就更容易了,但我们学习的是技术。当然也为以后自己的软件不会被轻易破解。
第一步。根据卷标,CPU序列号,生成机器码
// 取得设备硬盘的卷标号
public static string GetDiskVolumeSerialNumber()
{
ManagementClass mc = new ManagementClass(“Win32_NetworkAdapterConfiguration”);
ManagementObject disk = new ManagementObject(“win32_logicaldisk.deviceid=”d:”");
disk.Get();
return disk.GetPropertyValue(“VolumeSerialNumber”).ToString();
}
//获得CPU的序列号
public static string getCpu()
{
string strCpu = null;
ManagementClass myCpu = new ManagementClass(“win32_Processor”);
ManagementObjectCollection myCpuConnection = myCpu.GetInstances();
foreach (ManagementObject myObject in myCpuConnection)
{
strCpu = myObject.Properties["Processorid"].Value.ToString();
break;
}
return strCpu;
}
//生成机器码
public static string getMNum()
{
string strNum = getCpu() + GetDiskVolumeSerialNumber();//获得24位Cpu和硬盘序列号
string strMNum = strNum.Substring(0, 24);//从生成的字符串中取出前24个字符做为机器码
return strMNum;
}
public static int[] intCode = new int[127];//存储密钥
public static int[] intNumber = new int[25];//存机器码的Ascii值
public static char[] Charcode = new char[25];//存储机器码字
public static void setIntCode()//给数组赋值小于10的数
{
for (int i = 1; i < intCode.Length; i++)
{
intCode[i] = i % 9;
}
}
第二步。根据机器码 生成注册码
//生成注册码
public static string getRNum()
{
setIntCode();//初始化127位数组
for (int i = 1; i < Charcode.Length; i++)//把机器码存入数组中
{
Charcode[i] = Convert.ToChar(getMNum().Substring(i – 1, 1));
}
for (int j = 1; j < intNumber.Length; j++)//把字符的ASCII值存入一个整数组中。
{
intNumber[j] = intCode[Convert.ToInt32(Charcode[j])] + Convert.ToInt32(Charcode[j]);
}
string strAsciiName = “”;//用于存储注册码
for (int j = 1; j < intNumber.Length; j++)
{
if (intNumber[j] >= 48 && intNumber[j] <= 57)//判断字符ASCII值是否0-9之间
{
strAsciiName += Convert.ToChar(intNumber[j]).ToString();
}
else if (intNumber[j] >= 65 && intNumber[j] <= 90)//判断字符ASCII值是否A-Z之间
{
strAsciiName += Convert.ToChar(intNumber[j]).ToString();
}
else if (intNumber[j] >= 97 && intNumber[j] <= 122)//判断字符ASCII值是否a-z之间
{
strAsciiName += Convert.ToChar(intNumber[j]).ToString();
}
else//判断字符ASCII值不在以上范围内
{
if (intNumber[j] > 122)//判断字符ASCII值是否大于z
{
strAsciiName += Convert.ToChar(intNumber[j] – 10).ToString();
}
else
{
strAsciiName += Convert.ToChar(intNumber[j] – 9).ToString();
}
}
}
return strAsciiName;
}
第三步。检查注册状况,若没有注册,可自定义试用
/// <summary>
/// 检查注册
/// </summary>
private void CheckRegist()
{
this.btn_reg.Enabled = true;
RegistryKey retkey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(“software”, true).CreateSubKey(“wxk”).CreateSubKey(“wxk.INI”);
foreach (string strRNum in retkey.GetSubKeyNames())//判断是否注册
{
if (strRNum == clsTools.getRNum())
{
thControl(true);
return;
}
}
thControl(false);
Thread th2 = new Thread(new ThreadStart(thCheckRegist2));
th2.Start();
}
}
/// <summary>
/// 验证试用次数
/// </summary>
private static void thCheckRegist2()
{
MessageBox.Show(“您现在使用的是试用版,该软件可以免费试用3000000次!”, “提示”, MessageBoxButtons.OK, MessageBoxIcon.Information);
Int32 tLong;
try
{
tLong = (Int32)Registry.GetValue(“HKEY_LOCAL_MACHINE\SOFTWARE\angel”, “UseTimes”, 0);
MessageBox.Show(“感谢您已使用了” + tLong + “次”, “提示”, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch
{
Registry.SetValue(“HKEY_LOCAL_MACHINE\SOFTWARE\angel”, “UseTimes”, 0, RegistryValueKind.DWord);
MessageBox.Show(“欢迎新用户使用本软件”, “提示”, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
tLong = (Int32)Registry.GetValue(“HKEY_LOCAL_MACHINE\SOFTWARE\angel”, “UseTimes”, 0);
if (tLong < 3000000)
{
int Times = tLong + 1;
Registry.SetValue(“HKEY_LOCAL_MACHINE\SOFTWARE\angel”, “UseTimes”, Times);
}
else
{
MessageBox.Show(“试用次数已到”, “警告”, MessageBoxButtons.OK, MessageBoxIcon.Warning);
Application.Exit();
}
}
C#生成软件注册码的更多相关文章
- 【转】基于RSA算法实现软件注册码原理初讨
1 前言 目前,商用软件和共享软件绝大部份都是采用注册码授权的方式来保证软件本身不被盗用,以保证自身的利益.尽管很多常用的许多软件系统的某些版本已经被别人破解,但对于软件特殊行业而言,注册码授权的方式 ...
- 随机生成MyEclipse注册码
package com.registercode; import java.io.BufferedReader;import java.io.IOException;import java.io.In ...
- msf生成软件
生成软件后门程序的命令 win7获取 生成内网软件 启动kali上的http服务 systemctl start apache2 开始msf控制台 msfconsole 使用监听模块 并查看配置 s ...
- pycharm 2016.1.4 软件注册码生成
昨天电脑忽然坏了,没办法只能电脑重做系统,最让我头疼的是面对新电脑的软件安装和配置..... 由于之前电脑很久没有升级过ide,所以pycharm一直停留在2016.1.4的版本,当我打开pychar ...
- python环境搭建-pycharm2016软件注册码
pycharm软件下载地址 https://www.jetbrains.com/pycharm/ 方法一: pycharm 2016 注册码 43B4A73YYJ-eyJsaWNlbnNlSWQiOi ...
- CSS雪碧图自动生成软件
下载地址 http://www.99css.com/1524/ 包含详细的下载地址.下载步骤以及使用教程 亮点:自动合成雪碧图+自动生成雪碧图background-position代码 简单过程 下载 ...
- 用python & bat写软件安装脚本 + HM NIS Edit自动生成软件安装脚本
2019-03-11更新:原来NSIS脚本也可以禁用64位文件操作重定向的! 1.在安装脚本的开始处定义 LIBRARY_X64. !include "MUI.nsh"!inclu ...
- Python Des加密与解密实现软件注册码、机器码
原理 判断路径下是否存在识别文件,若存在就解密对比,若不存在就进入机器码注册: 获取系统C盘序列号作为识别ID,并添加随机数作为混淆,生成最终机器码. 将机器码发给软件开发者,开发者将机器码解密后,添 ...
- Office Word文件批量生成软件
一.软件用途 如果Word文件模板固定,只是要素信息不同,则可以使用本软件批量生成Word文件. 软件下载地址(2020-12-6更新):https://files.cnblogs.com/files ...
随机推荐
- Delphi实现文件关联
文件关联为我们带来很多的方便.Delphi自带有注册表对象TRegistry,可以通过它取得或改变注册表相关键值的内容. Function GetAssociatedExec(FileExt: Str ...
- 微信公众平台开发localStorage数据总是被清空
我把现在项目中的用户数据存储过程改成本地的,只用localStorage,但是随之而来很多问题,原因就是localStorage只有很短的有效时间,退出公众号,关闭微信都会清空.最不能容忍的是用户还在 ...
- 《DevOps故障排除:Linux服务器运维最佳实践》读书笔记
首先,这本书是Linux.CN赠送的,多谢啦~ http://linux.cn/thread-12733-1-1.html http://linux.cn/thread-12754-1-1.html ...
- 句柄(handle)
< Back 句柄,在windows编程中用来标识: *.模块(module) *.任务(task) *.实例(instance) *.文件(file) *.内存块(block of memor ...
- cdh5.4、cm5.4 安装详细步骤
安装准备: 1.centos6.5 64位 虚拟机,内存分配4G.硬盘位20G 2.cm5.4 cdh5.4 包 安装步骤 一.centos安装完后,进行系统配置 1.关闭防火墙 service ip ...
- ansible文件模块使用
1. 文件组装模块-assemble assemble主要是将多份配置文件组装为一份配置文件. 参数 必填 默认 选项 说明 Backup 否 No Yes/no 是否创建备份文件,使用时间戳 Del ...
- Web Farm和Web Garden的区别
在这篇博文中,我将确切剖析Web Farm和Web Garden的区别和原理,以及使用它们的利弊.进一步地,我将介绍如何在各个版本的IIS中创建Web Garden. 英文原文 | Abhijit J ...
- Delphi下使用OpenOffice+JodConverter+SWFtools进行文件转换
目的:office文件转换为PDF或SWF,最终可使用Flexpaper调用adobe flash player进行浏览 放弃两个文件转换工具: 1.FlashPaper,转换出的文件由于自带工具栏, ...
- dom 封装表单控件
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...
- onAttachedToWindow()在整个Activity生命周期的位置及使用
onAttachedToWindow在整个Activity的生命周期中占据什么位置? 为什么要在onAttachedToWindow中修改窗口尺寸? 一.onAttachedToWindow在Acti ...