110,502
社区成员
发帖
与我相关
我的任务
分享
//创建注册表信息
private void CreateRegister()
{
//添加安装时间
RegistryKey rk = Registry.LocalMachine;
RegistryKey software = rk.OpenSubKey("SOFTWARE", true);
RegistryKey jyg = software.CreateSubKey("物流大管家");
jyg.SetValue("SetupTime", JYG.Common.PublicMethods.Encode(DateTime.Now.ToString("yyyy-MM-dd")));
//使用次数
jyg.SetValue("UseTime", JYG.Common.PublicMethods.Encode("0"));
}
//检查试用时间
private void CheckTrialDate()
{
RegistryKey rk = Registry.LocalMachine;
RegistryKey software = rk.OpenSubKey("SOFTWARE", true);
try
{
int useTime = int.Parse(JYG.Common.PublicMethods.Decode(
software.OpenSubKey("物流大管家", true).GetValue("UseTime").ToString()));
int configUseTime = int.Parse(JYG.Common.PublicMethods.GetUseTime());
if (useTime > configUseTime)
{
MessageBox.Show("您的试用期已过,请购买正版!\r\n详情请登录 " +
"www.hrconsult.com.cn,或拨打联系电话 010-63331678", "提示窗体",
MessageBoxButtons.OK, MessageBoxIcon.Information);
Application.Exit();
}
else
{
//增加注册表使用次数
useTime++;
software.OpenSubKey("物流大管家", true).SetValue("UseTime",
JYG.Common.PublicMethods.Encode(useTime.ToString()));
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "错误窗体",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}