C # Implementing Software Registration

Source: Internet
Author: User

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>
Form loading
</summary>
<param name= "Sender" ></param>
<param name= "E" ></param>
private void Frmmainform_load (object sender, EventArgs e)
{
Determine if the software is registered
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 software is registered!" ";
this.btnReg.Enabled = false;
Return
}
}
This. Text = "This software has not been registered!" ";
This.btnReg.Enabled = true;
MessageBox.Show ("You are now using a trial version, you can try it for free 30 times!") "," Information ", messageboxbuttons.ok,messageboxicon.information);
Int32 Tlong;
Try
{
Tlong= (Int32) registry.getvalue ("Hkey_local_machine\\software\\angel", "Usetimes", 0);
MessageBox.Show ("You have used the" + Tlong + "times!) "," Information ", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
Catch
{
MessageBox.Show ("Welcome to use the software!") "," Information ", 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 ("The number of trials has arrived!") Do you need to register? "," Information ", Messageboxbuttons.yesno, MessageBoxIcon.Information);
if (result = = Dialogresult.yes)
{
Frmregisterform.state = false;
Btnreg_click (sender, E);
}
Else
{
Application.exit ();
}
}
}
}
}

C # Implementing Software Registration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.