/// <summary> /// 注册 /// </summary> private void btnReg_Click(object sender, EventArgs e) { var regCode = txtRegCode.Text.Trim(); if (regCode == "") { MessageBox.Show("注册码输入不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } this.btnReg.Enabled = false; this.btnCancel.Enabled = false; var _regCode = _softReg.getRNum(_macCode); // 真实注册码 if (!regCode.Equals(_regCode)) { MessageBox.Show("注册码验证失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); this.btnReg.Enabled = !this.btnReg.Enabled; this.btnCancel.Enabled = !this.btnCancel.Enabled; return; } // 执行注册委托 RegisterAction?.Invoke(_regCode); this.DialogResult = DialogResult.OK; }
SoftReg softreg = new SoftReg();//实例化公共类对象 private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "") { MessageBox.Show("机器码输入不能为空!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { textBox2.Text = softreg.getRNum(); } }
//窗体加载时,初始化视频卡,并开始预览视频 private void frmMain_Load(object sender, EventArgs e) { plVideo1.BackgroundImage = null; RegistryKey retkey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("software", true).CreateSubKey("wxk").CreateSubKey("wxk.INI"); foreach (string strRNum in retkey.GetSubKeyNames())//判断是否注册 { if (strRNum == softreg.getRNum()) { this.Text = "家庭视频监控系统(已注册)" + admin; string strSql = "select * from tb_admin where name='" + admin + "' and power=0"; DataSet ds = dataoperate.getDs(strSql, "tb_admin"); if (ds.Tables[0].Rows.Count > 0) { btnSetMonitor.Enabled = btnAutoMonitor.Enabled = false; //不显示仅管理员用户可用的按钮。 } btnReg.Enabled = false; startMonitor(); return; //return跳出了此方法,因此不会执行接下来的语句。 } } this.Text = "家庭视频监控系统(未注册)"; btnReg.Enabled = true; btnSetMonitor.Enabled = btnAutoMonitor.Enabled = false; //不显示仅注册用户可用的按钮。 startMonitor(); 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 { 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 < 30) { int Times = tLong + 1; Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\angel", "UseTimes", Times); } else { MessageBox.Show("试用次数已到", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); Application.Exit(); } }
//窗体加载时,初始化视频卡,并开始预览视频 private void frmMain_Load(object sender, EventArgs e) { frmWelcome frmwelcome = new frmWelcome(); frmwelcome.ShowDialog(); dtLTime = DateTime.Now; timer1.Start(); timer2.Start(); setVideoBG(""); plVideo1.BorderStyle = BorderStyle.Fixed3D; RegistryKey retkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("software", true).CreateSubKey("wxk").CreateSubKey("wxk.INI"); foreach (string strRNum in retkey.GetSubKeyNames())//判断是否注册 { if (strRNum == softreg.getRNum()) { this.Text = "多路视频监控模块(已注册)"; btnReg.Enabled = false; startMonitor(); return; } } this.Text = "多路视频监控模块(未注册)"; btnReg.Enabled = true; btnSetMonitor.Enabled = btnAutoMonitor.Enabled = false; startMonitor(); 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 { 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 < 30) { int Times = tLong + 1; Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\angel", "UseTimes", Times); } else { MessageBox.Show("试用次数已到", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); Application.Exit(); } }
private void btnReg_Click(object sender, EventArgs e) { if (txtRNum.Text.Equals(softreg.getRNum())) { RegistryKey retkey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("software", true).CreateSubKey("wxk").CreateSubKey("wxk.INI").CreateSubKey(txtRNum.Text); retkey.SetValue("UserName", "tsoft"); MessageBox.Show("注册成功!", "注册", MessageBoxButtons.OK, MessageBoxIcon.Information); showMain(); } else { MessageBox.Show("注册失败!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
static void Main() { SoftReg SR = new SoftReg(); string key = ConfigHelper.GetConfigString("lience"); if (key == SR.getRNum()) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } else { MessageBox.Show("Lience有误!请激活!"); } }
SoftReg softreg = new SoftReg();//实例化公共类对象 private void frmMain_Load(object sender, EventArgs e) { RegistryKey retkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("software", true).CreateSubKey("mrwxk").CreateSubKey("mrwxk.ini"); //打开注册表项 foreach (string strRNum in retkey.GetSubKeyNames()) //判断是否注册 { if (strRNum == softreg.getRNum()) //判断注册码是否相同 { this.Text = "限制软件的使用次数(已注册)"; button1.Enabled = false; return; } } this.Text = "限制软件的使用次数(未注册)"; button1.Enabled = true; MessageBox.Show("您现在使用的是试用版,该软件可以免费试用30次!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); Int32 tLong; try { //获取软件的已经使用次数 tLong = (Int32)Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\tryTimes", "UseTimes", 0); MessageBox.Show("感谢您已使用了" + tLong + "次", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch { //首次使用软件 Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\tryTimes", "UseTimes", 0, RegistryValueKind.DWord); MessageBox.Show("欢迎新用户使用本软件", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } //获取软件已经使用次数 tLong = (Int32)Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\tryTimes", "UseTimes", 0); if (tLong < 30) { int Times = tLong + 1;//计算软件本次是第几次使用 //将软件使用次数写入注册表 Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\tryTimes", "UseTimes", Times); } else { MessageBox.Show("试用次数已到", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); Application.Exit();//退出应用程序 } }
private void button1_Click(object sender, EventArgs e) { if (textBox2.Text == "") { MessageBox.Show("注册码输入不能为空!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (textBox2.Text.Equals(softreg.getRNum())) { RegistryKey retkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("software", true).CreateSubKey("mrwxk").CreateSubKey("mrwxk.ini").CreateSubKey(textBox2.Text); retkey.SetValue("UserName", "mrsoft"); MessageBox.Show("注册成功,程序需要重新加载!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Hide(); Frm_Main frmmain = new Frm_Main(); frmmain.Show(); } else { MessageBox.Show("注册码输入错误!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void btnReg_Click(object sender, EventArgs e) { if (txtRNum.Text == "") { MessageBox.Show("×¢²áÂëÊäÈë²»ÄÜΪ¿Õ£¡", "¾¯¸æ", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (txtRNum.Text.Equals(softreg.getRNum())) { RegistryKey retkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("software", true).CreateSubKey("wxk").CreateSubKey("wxk.INI").CreateSubKey(txtRNum.Text); retkey.SetValue("UserName", "mrsoft"); MessageBox.Show("×¢²á³É¹¦,³ÌÐòÐèÒªÖØмÓÔØ£¡", "Ìáʾ", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Hide(); frmMain frmmain = new frmMain(); frmmain.Show(); } else { MessageBox.Show("×¢²áÂëÊäÈë´íÎó£¡", "´íÎó", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void button1_Click(object sender, EventArgs e) { textBox1.Text = SR.getRNum(); }