使应用程序30天跟踪版本,然后激活365天 [英] Make application 30 days trail version and then activate for 365 days

查看:81
本文介绍了使应用程序30天跟踪版本,然后激活365天的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个小样本申请。我在VS-2010和C#Windows窗体中创建了它。

I have a small sample application. I made it in VS-2010 and C# Windows Forms.

我想将我的应用程序作为跟踪版本使用30天。当我们激活它时,它必须运行365天。 

I want to make my application as trail version for 30 days. And as we activate it, it must run for 365 days. 

我是第一次尝试这个。我想了解如何制作它的程序。

I am trying this for first time. And I want to know the procedure for this on how to make it.

我可以使用
此链接
。但是我没有找到任何程序让激活后的365天运行申请。 

I am able to make trail to run for 30 days using this link. But I did not find any procedure to make application run for 365 days after activating. 

请帮助解决这个问题。

问候,Humaira。

Regards, Humaira.

推荐答案

Hi Humaira,

Hi Humaira,

对不起,迟到的回复。

我查看了你提供的文件,事实上,我们通常会把时间写到注册表然后再读它,所以如果你能实现30几天,然后你可以改变30到365来实现你需要的功能。

I view the document what you have provided, in fact, we usually write time to the registry and then read it, so if you can achieve 30 days, then you can change 30 to 365 to achieve the function you need.

我也做了一个简单的演示(只是课程),你可以实现跟踪版本,请参考它如下:

I also make a simple demo(just class) for you to achieve the trail version, and please refer to it as below:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
 
namespace Application1
{
    class TrialTimeManager
    {
        /// <summary>
        /// A Temporary variable.
        /// </summary>
        private string temp = "";
 
        /// <summary>
        /// The constructor.
        /// </summary>
        public TrialTimeManager()
        {
 
        }
 
        /// <summary>
        /// Sets the new date +31 days add for trial.
        /// </summary>
        public void SetNewDate()
        {
            DateTime newDate = DateTime.Now.AddDays(31);
            temp = newDate.ToLongDateString();
            StoreDate(temp);
        }
 
        /// <summary>
        /// Checks if expire or NOT.
        /// </summary>
        public void Expired()
        {
            string d = "";
            using (Microsoft.Win32.RegistryKey key =
                Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Test"))
            {
                 d = (String)key.GetValue("Date");
            }
            DateTime now = DateTime.Parse(d);
            int day = (now.Subtract(DateTime.Now)).Days;
            if (day > 30){}
            else if (0 < day && day <= 30){
                 string daysLeft = string.Format("{0} days more to expire", now.Subtract(DateTime.Now).Days);
                 MessageBox.Show(daysLeft);
            }
            else if (day <= 0){
                /* Fill with more code, once it has expired, what will happen nex! */
            }
        }
 
        /// <summary>
        /// Stores the new date value in registry.
        /// </summary>
        /// <param name="value"></param>
        private void StoreDate(string value)
        {
            try
            {
                using (Microsoft.Win32.RegistryKey key =
                    Microsoft.Win32.Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Test"))
                {
                    key.SetValue("Date", value, Microsoft.Win32.RegistryValueKind.String);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
}

在此演示中,您可以添加if语句来确定用户是否已激活,如果是,则将30天更改为365以达到目的:

In this demo, you can add a if statement to determine whether the user is activated, if so, change the 30 days to 365 to achieve the purpose:

if(...)//whether it is activated            
{
            if (day > 365){}
            else if (0 < day && day <= 365){
                 string daysLeft = string.Format("{0} days more to expire", now.Subtract(DateTime.Now).Days);
                 MessageBox.Show(daysLeft);
            }
            else if (day <= 0){
                /* Fill with more code, once it has expired, what will happen nex! */
            }
}

此外,您可以参考以下有关申请试用的链接:

Also you can refer to the following link about application trial:

< a href ="https://www.codeproject.com/Articles/15496/Application-Trial-Maker"> https://www.codeproject.com/Articles/15496/Application-Trial-Maker

希望这有帮助!

最好的问候,

Stanly


这篇关于使应用程序30天跟踪版本,然后激活365天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆