系统试用期限制 (C#) c# 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 if( DateTime.Now>Convert.ToDateTime("2013-04-30")) MessageBox.Show("试用版已过期");else 正常运行; 安装时取internet时间保存,加密写文件然后每次运行时取internet时间对比,如果超过规定时间则程序退出,提示过期 #region 注册此软件 this.btnReg.Visible = true; this.Text = "此软件尚未注册!"; this.btnReg.Enabled = true; MessageBox.Show("您现在使用的是试用版,可以免费试用10次!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information); Int32 tLong; try { tLong = (Int32)Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\SoftUse", "UseTimes", 0); MessageBox.Show("您已经使用了" + tLong + "次!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch { MessageBox.Show("欢迎使用本软件!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information); Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\SoftUse", "UseTimes", 0, RegistryValueKind.DWord); } tLong = (Int32)Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\SoftUse", "UseTimes", 0); if (tLong < 10) { int tTimes = tLong + 1; Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\SoftUse", "UseTimes", tTimes); } else { DialogResult result = MessageBox.Show("此软件的试用次数已到!您是否需要注册?", "温馨提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { FrmRegister.state = false; btnReg_Click(sender, e); } else { Application.Exit(); } } #endregion注册:RegistryKey retkey = Registry.CurrentUser.OpenSubKey("Software", true).CreateSubKey("自定义一个名称").CreateSubKey("自定义一个名称.INI").CreateSubKey(txtRNum.Text); retkey.SetValue("UserName", "Rsoft");登录的时候: //判断软件是否注册RegistryKey retkey = Registry.CurrentUser.OpenSubKey("SOFTWARE", true).CreateSubKey("自定义一个名称").CreateSubKey("自定义一个名称.INI"); foreach (string strRNum in retkey.GetSubKeyNames()) {//这里做判断} 安装的时候把系统时间写入注册表,每次登陆的时候对比下当前时间和注册表时间看过了试用期限么,然后if else 把2个时间写入注册表,安装时间和最后使用时间。安装的时候,把安装时间写入注册表。每次使用的时候,判断一下当前时间,如果(当前时间>安装时间+试用时间) 或者 (当前时间 < 安装时间)就提示到期。 http://blog.csdn.net/zb872676223/article/details/17416825 怎么证明SQL的表变量不参与事务 Linq 查找维数最大的数 求Winform控件的属性及事件的用法? 新手求教记事本程序 DataSet记录集指针控制 求助!! .net 线程、方法、类基础 与 树和递归 有关的问题. 高手给翻译一个VBS TO C#关于HTMLENCODE 如何在webform中获得当前机器的可用打印机列表(包括本地的和网络的)? 快快快·一个小问题,在线等候,及时给分!!!! EF实例问题.做到一半.提示未将引用设置到对象的实例. 小弟刚学习C#,c#怎么单击窗体依次变色,下面是我的源码,不知道哪里出错了,请各位大神看下!
MessageBox.Show("试用版已过期");
else
正常运行;
#region 注册此软件
this.btnReg.Visible = true; this.Text = "此软件尚未注册!";
this.btnReg.Enabled = true;
MessageBox.Show("您现在使用的是试用版,可以免费试用10次!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
Int32 tLong;
try
{
tLong = (Int32)Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\SoftUse", "UseTimes", 0);
MessageBox.Show("您已经使用了" + tLong + "次!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch
{
MessageBox.Show("欢迎使用本软件!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\SoftUse", "UseTimes", 0, RegistryValueKind.DWord);
}
tLong = (Int32)Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\SoftUse", "UseTimes", 0);
if (tLong < 10)
{
int tTimes = tLong + 1;
Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\SoftUse", "UseTimes", tTimes);
}
else
{
DialogResult result = MessageBox.Show("此软件的试用次数已到!您是否需要注册?", "温馨提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
FrmRegister.state = false;
btnReg_Click(sender, e);
}
else
{
Application.Exit();
}
}
#endregion
注册:RegistryKey retkey = Registry.CurrentUser.OpenSubKey("Software", true).CreateSubKey("自定义一个名称").CreateSubKey("自定义一个名称.INI").CreateSubKey(txtRNum.Text);
retkey.SetValue("UserName", "Rsoft");
登录的时候: //判断软件是否注册RegistryKey retkey = Registry.CurrentUser.OpenSubKey("SOFTWARE", true).CreateSubKey("自定义一个名称").CreateSubKey("自定义一个名称.INI");
foreach (string strRNum in retkey.GetSubKeyNames())
{
//这里做判断
}
if else
安装的时候,把安装时间写入注册表。
每次使用的时候,判断一下当前时间,如果(当前时间>安装时间+试用时间) 或者 (当前时间 < 安装时间)
就提示到期。