C# .NET - How to Make my Windows Form Application Expire in 1week or after few installations

Asked By Ajay Paritala on 14-Jun-12 05:11 PM
Hi,

I've created a windows form application in c#.NET now i need to add a trail version i mean application should expire after 4 to 5 days of installation. Or It software should work only for few installations.
Can some one help me with this please.
[)ia6l0 iii replied to Ajay Paritala on 14-Jun-12 10:56 PM
I have tried many kits, and found them to be more pain than gain. I have tried to sneak into registry, write logs in windows folders and custom-invented some date logics which would fail even if the user back-dated his system date time. 

What I have found is that there methods are not fool-proof and best way to do this to manage it through a database. 



Hope this helps.
RAJASEKHAR RAJENDRAN replied to Ajay Paritala on 15-Jun-12 12:05 AM
Ajay,

You can use the  library to easily create a trial version of your application  as Suggested on the link
http://www.codeproject.com/Articles/15496/Application-Trial-Maker 



Thanks & Regards,
Rajasekhar.R



Jitendra Faye replied to Ajay Paritala on 15-Jun-12 12:26 AM
For this you can use Registry concept.

Means while installing your application you have to store current date in registry.

Now while loading your application you have to check that registry value with current date ,

TRy like this-

//While installing

        RegistryKey regKey ;
     
        regKey = Registry.CurrentUser.CreateSubKey("SubKeyname");
        regKey.SetValue("KeyName","Currentdate"); 


      
//While loading check for key value

        regKey = Registry.CurrentUser.OpenSubKey("SubKeyname");
        DateTime date = Convert.ToDateTime(regKey.GetValue("KeyName")); 


  //Now check  with Expiration time

        if (date > date.AddDays(30))
        {
          //Software expired
        }

        else
        {
          //Continue execution
        }


TRy this AND LET ME KNOW.
Jitendra Faye replied to Ajay Paritala on 15-Jun-12 12:28 AM
fOR ONE WEEK -

Change previous post like this-

//While installing

        RegistryKey regKey ;
    
        regKey = Registry.CurrentUser.CreateSubKey("SubKeyname");
        regKey.SetValue("KeyName","Currentdate");


     
//While loading check for key value

        regKey = Registry.CurrentUser.OpenSubKey("SubKeyname");
        DateTime date = Convert.ToDateTime(regKey.GetValue("KeyName"));


  //Now check  with Expiration time

        if (date > date.AddDays(7))
        {
          //Software expired
        }

        else
        {
          //Continue execution
        }



TRy this AND LET ME KNOW.
Neha Garg replied to Ajay Paritala on 15-Jun-12 12:31 AM

Hello Ajay,

 For that you need to add the Algorithm in your code to specify the trail period of the software application and remind the users to activate the application by register the product.

 It will ask for product key after the specific time given by you.....

 Open the below link with the complete information with the code.....

 http://www.c-sharpcorner.com/uploadfile/tanmayit08/make-your-application-with-trial-version/

[)ia6l0 iii replied to Ajay Paritala on 15-Jun-12 11:07 AM
Also note that , you need administrator privileges to write and read from registry. It might not feasible with all operating systems and on all user accounts.