基本信息
源码名称:C# winform软件 注册、授权例子源码(可做注册机)
源码大小:0.07M
文件格式:.rar
开发语言:C#
更新时间:2016-02-05
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
客户端验证代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
namespace 注册机
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
SoftReg softReg = new SoftReg();
private void Form1_Load(object sender, EventArgs e)
{
try
{
//判断软件是否注册
RegistryKey retkey = Registry.CurrentUser.OpenSubKey("SOFTWARE", true).CreateSubKey("mySoftWare").CreateSubKey("Register.INI");
foreach (string strRNum in retkey.GetSubKeyNames())
{
if (strRNum == softReg.GetRNum())
{
this.labRegInfo.Text = "此软件已注册!";
this.btnReg.Enabled = false;
return;
}
}
this.labRegInfo.Text = "此软件尚未注册!";
this.btnReg.Enabled = true;
MessageBox.Show("您现在使用的是试用版,可以免费试用30次!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
Int32 tLong; //已使用次数
try
{
tLong = (Int32)Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\mySoftWare", "UseTimes", 0);
MessageBox.Show("您已经使用了" tLong "次!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch
{
MessageBox.Show("欢迎使用本软件!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\mySoftWare", "UseTimes", 0, RegistryValueKind.DWord);
}
//判断是否可以继续试用
tLong = (Int32)Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\mySoftWare", "UseTimes", 0);
if (tLong < 30)
{
int tTimes = tLong 1;
Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\mySoftWare", "UseTimes", tTimes);
}
else
{
DialogResult result = MessageBox.Show("试用次数已到!您是否需要注册?", "信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if (result == DialogResult.Yes)
{
FormRegister.state = false; //设置软件状态为不可用
btnReg_Click(sender, e); //打开注册窗口
}
else
{
Application.Exit();
}
}
}catch(Exception ex){
MessageBox.Show("请以管理员身份运行!");
this.Close();
}
}
private void btnReg_Click(object sender, EventArgs e)
{
FormRegister frmRegister = new FormRegister();
frmRegister.ShowDialog();
}
private void btnClose_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}
注册机部分代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace 生成注册码
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
SoftReg softReg = new SoftReg();
private void btnCreate_Click(object sender, EventArgs e)
{
try
{
string strHardware = this.txtHardware.Text;
string strLicence = softReg.GetRNum(strHardware);
this.txtLicence.Text = strLicence;
}
catch (System.Exception ex)
{
MessageBox.Show("输入的机器码格式错误!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
private void btnExit_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}