资源简介

本实例可以通过将软件的使用次数写入注册表来实现软件的试用。

资源截图

代码片段和文件信息

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 Ex08_13
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        
        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();
                }
          
        }

        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 = “欢迎新用户使用本软件“;
            }
        }
    }
}


 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     目录          0  2007-12-15 14:39  Ex08_13

     目录          0  2007-12-15 14:39  Ex08_13\Ex08_13

     目录          0  2007-12-15 14:39  Ex08_13\Ex08_13\Ex08_13

     目录          0  2007-12-15 14:39  Ex08_13\Ex08_13\Ex08_13\bin

     目录          0  2007-12-15 14:39  Ex08_13\Ex08_13\Ex08_13\bin\Debug

     文件      20480  2007-07-11 11:27  Ex08_13\Ex08_13\Ex08_13\bin\Debug\Ex08_13.exe

     文件      22016  2007-07-11 11:27  Ex08_13\Ex08_13\Ex08_13\bin\Debug\Ex08_13.pdb

     文件       5632  2007-07-11 11:27  Ex08_13\Ex08_13\Ex08_13\bin\Debug\Ex08_13.vshost.exe

     文件       3221  2007-07-11 11:27  Ex08_13\Ex08_13\Ex08_13\Ex08_13.csproj

     文件       1505  2007-07-11 11:27  Ex08_13\Ex08_13\Ex08_13\Form1.cs

     文件       3934  2007-07-11 11:27  Ex08_13\Ex08_13\Ex08_13\Form1.Designer.cs

     文件       5814  2007-07-11 11:27  Ex08_13\Ex08_13\Ex08_13\Form1.resx

     目录          0  2007-12-15 14:39  Ex08_13\Ex08_13\Ex08_13\obj

     目录          0  2007-12-15 14:39  Ex08_13\Ex08_13\Ex08_13\obj\Debug

     文件        842  2007-07-11 11:27  Ex08_13\Ex08_13\Ex08_13\obj\Debug\Ex08_13.csproj.GenerateResource.Cache

     文件      20480  2007-07-11 11:27  Ex08_13\Ex08_13\Ex08_13\obj\Debug\Ex08_13.exe

     文件        180  2007-07-11 11:27  Ex08_13\Ex08_13\Ex08_13\obj\Debug\Ex08_13.Form1.resources

     文件      22016  2007-07-11 11:27  Ex08_13\Ex08_13\Ex08_13\obj\Debug\Ex08_13.pdb

     文件        180  2007-07-11 11:27  Ex08_13\Ex08_13\Ex08_13\obj\Debug\Ex08_13.Properties.Resources.resources

     目录          0  2007-12-15 14:39  Ex08_13\Ex08_13\Ex08_13\obj\Debug\TempPE

     文件        268  2007-07-11 11:27  Ex08_13\Ex08_13\Ex08_13\obj\Ex08_13.csproj.FileList.txt

     文件        466  2007-07-11 11:27  Ex08_13\Ex08_13\Ex08_13\Program.cs

     目录          0  2007-12-15 14:39  Ex08_13\Ex08_13\Ex08_13\Properties

     文件       1162  2007-07-11 11:27  Ex08_13\Ex08_13\Ex08_13\Properties\AssemblyInfo.cs

     文件       2868  2007-07-11 11:27  Ex08_13\Ex08_13\Ex08_13\Properties\Resources.Designer.cs

     文件       5612  2007-07-11 11:27  Ex08_13\Ex08_13\Ex08_13\Properties\Resources.resx

     文件       1090  2007-07-11 11:27  Ex08_13\Ex08_13\Ex08_13\Properties\Settings.Designer.cs

     文件        249  2007-07-11 11:27  Ex08_13\Ex08_13\Ex08_13\Properties\Settings.settings

     文件        910  2007-07-11 11:27  Ex08_13\Ex08_13\Ex08_13.sln

     文件      14848  2007-07-11 11:27  Ex08_13\Ex08_13\Ex08_13.suo

............此处省略3个文件信息

评论

共有 条评论