限软件的使用次数

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
namespace 限软件的使用次数
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                Int32 tLong = (Int32)Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\angel", "UserTimes", 0);
                label3.Text = "感谢您已使用了" + tLong + "次";
            }
            catch
            {
                Registry.SetValue("HKEY_LOCAL_MACHINE\SOFTWARE\angel", "UserTimes", 0, RegistryValueKind.DWord);
                label3.Text = "欢迎新用户使用本软件";
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Int32 tLong = (Int32)Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\angel", "UserTimes", 0);
            if (tLong < 10)
            {
                int Times = tLong + 1;
                Registry.SetValue("HKEY_LOCAL_MACHINE\SOFTWARE\angel", "UserTimes", Times);
            }
            else
            {
                MessageBox.Show("试用期已到");
                Application.Exit();
            }
        }
    }
}

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/jingang123gz/archive/2007/11/06/1869164.aspx

posted @ 2009-08-17 21:24  oraclejava  阅读(222)  评论(0)    收藏  举报