You can write the custom class to track it as:
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){
}
}
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);
}
}
}
}