c#實現軟體註冊

來源:互聯網
上載者:User

標籤:blog   http   io   ar   os   使用   sp   for   on   

http://www.cnblogs.com/ynbt/archive/2011/11/02/2233470.html
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;

namespace SoftRegister
{
public partial class frmMainForm : Form
{
public frmMainForm()
{
InitializeComponent();
}
SoftReg softReg = new SoftReg();
private void btnClose_Click(object sender, EventArgs e)
{
Application.Exit();
}

private void btnReg_Click(object sender, EventArgs e)
{
frmRegisterForm frmRegister = new frmRegisterForm();
frmRegister.ShowDialog();
}

///<summary>
/// 表單載入
///</summary>
///<param name="sender"></param>
///<param name="e"></param>
private void frmMainForm_Load(object sender, EventArgs e)
{
//判斷軟體是否註冊
RegistryKey retkey = Registry.CurrentUser.OpenSubKey("SOFTWARE", true).CreateSubKey("wxf").CreateSubKey("wxf.INI");
foreach (string strRNum in retkey.GetSubKeyNames())
{
if (strRNum == softReg.GetRNum())
{
this.lblRegInfo.Text = "此軟體登入!";
this.btnReg.Enabled = false;
return;
}
}
this.Text = "此軟體尚未註冊!";
this.btnReg.Enabled = true;
MessageBox.Show("您現在使用的是試用版,可以免費試用30次!","資訊",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
{
MessageBox.Show("歡迎使用本軟體!","資訊",MessageBoxButtons.OK,MessageBoxIcon.Information);
Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Angel","UseTimes",0,RegistryValueKind.DWord);
}
tLong = (Int32)Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Angel", "UseTimes", 0);
if (tLong < 30)
{
int tTimes = tLong + 1;
Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Angel", "UseTimes", tTimes);
}
else
{
DialogResult result = MessageBox.Show("試用次數已到!您是否需要註冊?", "資訊", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if (result == DialogResult.Yes)
{
frmRegisterForm.state = false;
btnReg_Click(sender, e);
}
else
{
Application.Exit();
}
}
}
}
}

c#實現軟體註冊

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.