基本信息
源码名称:C# 软件注册+注册机+写注册表 源码下载
源码大小:0.04M
文件格式:.7z
开发语言:C#
更新时间:2016-08-04
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 1 元×
微信扫码支付:1 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
为c# 软件添加注册功能,通过注册机和写入注册表方式
using System;
using System.Windows.Forms;
using System.Threading;
using System.IO;
using Common;
namespace RegistSoft0918
{
public partial class FormMain : Form
{
private string encryptComputer = string.Empty;
private bool isRegist = false;
private const int timeCount = 30;
public FormMain()
{
InitializeComponent();
Control.CheckForIllegalCrossThreadCalls = false;
}
private void FormMain_Load(object sender, EventArgs e)
{
string computer = ComputerInfo.GetComputerInfo();
encryptComputer = new EncryptionHelper().EncryptString(computer);
if (CheckRegist() == true)
{
lbRegistInfo.Text = "已注册";
}
else
{
lbRegistInfo.Text = "待注册,运行十分钟后自动关闭";
RegistFileHelper.WriteComputerInfoFile(encryptComputer);
TryRunForm();
}
}
/// <summary>
/// 试运行窗口
/// </summary>
private void TryRunForm()
{
Thread threadClose = new Thread(CloseForm);
threadClose.IsBackground = true;
threadClose.Start();
}
private bool CheckRegist()
{
EncryptionHelper helper = new EncryptionHelper();
string md5key = helper.GetMD5String(encryptComputer);
return CheckRegistData(md5key);
}
private bool CheckRegistData(string key)
{
if (RegistFileHelper.ExistRegistInfofile() == false)
{
isRegist = false;
return false;
}
else
{
string info = RegistFileHelper.ReadRegistFile();
var helper = new EncryptionHelper(EncryptionKeyEnum.KeyB);
string registData = helper.DecryptString(info);
if (key == registData)
{
isRegist = true;
return true;
}
else
{
isRegist = false;
return false;
}
}
}
private void CloseForm()
{
int count = 0;
while (count < timeCount && isRegist == false)
{
if (isRegist == true)
{
return;
}
Thread.Sleep(1 * 1000);
count ;
}
if (isRegist == true)
{
return;
}
else
{
this.Close();
}
}
private void btnRegist_Click(object sender, EventArgs e)
{
if (lbRegistInfo.Text == "已注册")
{
MessageBox.Show("已经注册~");
return;
}
string fileName = string.Empty;
OpenFileDialog openFileDialog = new OpenFileDialog();
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
fileName = openFileDialog.FileName;
}
else
{
return;
}
string localFileName = string.Concat(
Environment.CurrentDirectory,
Path.DirectorySeparatorChar,
RegistFileHelper.RegistInfofile);
if (fileName != localFileName)
File.Copy(fileName, localFileName, true);
if (CheckRegist() == true)
{
lbRegistInfo.Text = "已注册";
MessageBox.Show("注册成功~");
}
}
}
}