c# - Code to check 30 days trial for my application -


hi have developed application using c# , wish restrict use 30days , after 30 days user should not able use application.i got following code online.what code should add in elseif(days<30) restrict use

#region using directives using system; using system.collections.generic; using system.linq; using system.text; using system.windows.forms; #endregion  namespace coder24 {     class trialtimemanager     {         /// <summary>         /// temporary variable.         /// </summary>         private string temp = "";          /// <summary>         /// constructor.         /// </summary>         public trialtimemanager()         {          }          /// <summary>         /// sets new date +31 days add 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 = 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 expire", now.subtract(datetime.now).days);                  messagebox.show(daysleft);             }             else if (day <= 0){                 /* fill more code, once has expired, happen nex! */             }         }          /// <summary>         /// stores 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);             }         }     } } 

this depends entirely on want have happen when trial expires.

you want end program. give them option of visiting website purchase license. maybe this:

if (day > 30) {     if (messagebox.show("trial expired. visit site purchase license?",         "trial expired!", messageboxbuttons.yesno) == dialogresult.yes)     {         process.start("http://www.yourwebsite.com");     }      environment.exit(0); } 

if have else in mind, or other requirements, update question more details.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -