C#软件试用天数小程序

….

     RegistryKey RootKey,RegKey;

    //项名为:HKEY_CURRENT_USER/Software
    RootKey = Registry.CurrentUser.OpenSubKey (“Software”,true);
   
    //
打开子项:HKEY_CURRENT_USER/Software/MyRegDataApp
    if ((RegKey = RootKey.OpenSubKey (“MyRegDataApp”,true)) == null)
    {
     RootKey.CreateSubKey(“MyRegDataApp”);//
不存在,则创建子项
     RegKey = RootKey.OpenSubKey (“MyRegDataApp”,true);
     RegKey.SetValue (“UseTime”,(object)9); //
创建键值,存储可使用次数
     MessageBox.Show (“
您可以免费使用本软件10次!“,”感谢您首次使用“);
     return;
    }

    try
    {
     object usetime = RegKey.GetValue (“UseTime”);//
读取键值,可使用次数
     MessageBox.Show (“
你还可以使用本软件 :”+ usetime.ToString ()+ “次!“,”确认“,MessageBoxButtons.OK ,MessageBoxIcon.Information );
     int newtime = Int32.Parse (usetime.ToString()) -1;

     if (newtime     {
      if (MessageBox.Show (“
继续使用,请购买本软件!“,”提示“,MessageBoxButtons.OK ,MessageBoxIcon.Information )== DialogResult.OK )
      {
       Application.Exit ();
      }
     }
     else
     {
      RegKey.SetValue (“UseTime”,(object)newtime);//
更新键值,可使用次数减1
     }
    }
    catch
    {
     RegKey.SetValue (“UseTime”,(object)10); //
创建键值,存储可使用次数
     MessageBox.Show (“
您可以免费使用本软件10次!“,”感谢您首次使用“);
     return;
    }
   
   }

文章知识点与官方知识档案匹配,可进一步学习相关知识小程序技能树首页概览3702 人正在系统学习中

来源:暖枫无敌

声明:本站部分文章及图片转载于互联网,内容版权归原作者所有,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2010年3月16日
下一篇 2010年3月17日

相关推荐