Click here to Skip to main content
15,889,867 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
I have one project that works fine... i need to make it as 30 days trial for client use... how can i make it in c# vs2008.
Posted

Perhaps this would help: Application Trial Maker[^]
 
Share this answer
 
Comments
Rajesh Anuhya 3-Feb-12 1:31am    
Good answer Mika, have my +5
--RA
Try
Application Trial Maker[^].
Here[^] is a forum discussion.
 
Share this answer
 
You can write the custom class to track it as:

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace TrialTrack
{
    class TrialTimeManager
    {
        private string temp = "";

        public TrialTimeManager(){}

        public void SetNewDate()
        {
            DateTime newDate = DateTime.Now.AddDays(31);
            temp = newDate.ToLongDateString();
            StoreDate(temp);
        }

        public void Expired()
        {
            string d = "";
            using (Microsoft.Win32.RegistryKey key =                Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\MyApp"))
            {
                 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){
                /* Expiration logic */
            }
        }

        private void StoreDate(string value)
        {
            try
            {
                using (Microsoft.Win32.RegistryKey key =                    Microsoft.Win32.Registry.LocalMachine.CreateSubKey(@"SOFTWARE\MyApp"))
                {
                    key.SetValue("Date", value, Microsoft.Win32.RegistryValueKind.String);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
}
 
Share this answer
 
Comments
Shanmugam Rathakrishnan 7-Feb-12 23:41pm    
hi in my program the registry key deleted at uninstall. so if i reinstall my program trial is continue to next 30 days. how to solve this problem.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900