Results 1 to 6 of 6

Thread: Trial version that expires after X amount of Days

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2016
    Posts
    95

    Trial version that expires after X amount of Days

    Hello! I have been searching multiple ways to create a timed trial of an application I am making but I do not know how. I have searched multiple posts and websites but none give clear way like some will just miss out on mentioning where code will go. Can anyone help me with this issue? I have seen that using a registry will help make it harder for someone to extend the trial or to just delete it and re-download it and start over again.

  2. #2
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,578

    Re: Trial version that expires after X amount of Days

    Implementing it is the easy part. Trying to make it bulletproof is very time-consuming and hard. The smartest thing to do is ask yourself how much money you really expect to lose from people extending the trial, then spend only up to that much development effort on trying to stop it.

    Inside the app is easy. Your app has a Sub Main you can access if you dig in settings. In there, you compare the current date/time to the install date/time, and don't let the app start if too long has passed.

    That creates two problems: "How do I store the install time securely?" and "How do I verify the current time securely?". Let's do them out of order.

    You could just use DateTime.Now to get the current time. But what if our dastardly user changes the system clock? Well, you can approach that a few ways. Maybe you also store the last time the user opened the app. That way you can see the time is earlier and refuse to start. But that's going to catch legitimate users if the Daylight Savings adjustment happens, or if they take their laptop with them as they travel across time zones. You can address those by using UTC, but savvy users can also figure out what's going on and endeavor to keep setting their clock to the same time every time they start it. So what you really need is a way to ask a trusted server for the current time. But a clever user could sniff and manipulate that message via a proxy, so you'll want to use HTTPS with certificate pinning AND encrypt the time code, for safety. Of course, this also means you have to figure out what to do for people who don't have an internet connection. A lot of people don't like it if your software won't work without one.

    That's one problem. Now, how to store the startup time on the machine?

    Well, you could put it in a file, the registry, wherever. But the user can edit those things. So you need to consider encrypting it. But they can also disassemble the program to find your encryption code, then use it to make a tool to change the value. You really can't trust anything on the user's machine, so you should probably just ask an activation server you run if the user is allowed to run it.

    In fact, that turns out to be the only "bulletproof" way to do a time-limited trial. Write a web application. That way you own the machine running code, and the user can't tamper with it.

    A more realistic recommendation for a desktop application is to not sweat it too badly. Most people aren't going to go to the length to reverse engineer even simple encryption code, and the kind of people who will frequently set their clock back aren't good customers. There's probably some third-party licensing components for sale you can use from reputable vendors. It's probably a couple hundred bucks. But writing something relatively "safe" will take you 3-4 days, which is probably worth more than you'll spend.
    This answer is wrong. You should be using TableAdapter and Dictionaries instead.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2016
    Posts
    95

    Re: Trial version that expires after X amount of Days

    Woah hahaha. I am just a novice programmer who just wants simple protection hahaha. I was just wanting help with a simple way that can protect againsts the clock change. I like your post though

  4. #4
    Frenzied Member jdc20181's Avatar
    Join Date
    Oct 2015
    Location
    Indiana
    Posts
    1,175

    Re: Trial version that expires after X amount of Days

    You can use a online clock to get time and date, that way it can't be messed with.

    Personally I think the most annoying way to prevent people trying to extend trial times, is to make it where they dont want to use it after the free trial.

    Limit the time the application runs! Create a timer make it run lets say 1 hour. After 1 hour is up. Restart the appkication or shut it off.

    Doing this will make the user know that he/shes trial has expired.

    Watermarks EXPIRED TRIAL VERSION BEING USED are also annoying.

    The whole point is to intemedate the user not to abuse the free trial.

    OR Just Charge a smaller fee for a trial use. That works also. Say 5% of the total price. Businesses will pay for trials, not so much for individuals - but a demo/trial fee isn't uncommon. And can save you a headache.

    You can also disable buttons and features after certain periods of time, use settings to save that informtion so it cant be overran.

    You have to get creative if you are looking to make a buck. You can also threaten legal action if theyuse it longer than the trial time. But thats expensive and not worth it really unless you are well established and have a lot of cash.
    Disclaimer: When code is given for example - it is merely a example.




    Unless said otherwise indicated - All Code snippets advice or otherwise that I post on this site, are expressly licensed under Creative Commons Attribution 4.0 International Please respect my copyrights.

  5. #5
    Frenzied Member jdc20181's Avatar
    Join Date
    Oct 2015
    Location
    Indiana
    Posts
    1,175

    Re: Trial version that expires after X amount of Days

    Below is a Converted from C# Sample of getting time from the internet:

    Code:
    Public Shared Function GetNistTime() As DateTime
    	Dim dateTime__1 As DateTime = DateTime.MinValue
    
    	Dim request As HttpWebRequest = DirectCast(WebRequest.Create("http://nist.time.gov/actualtime.cgi?lzbc=siqm9b"), HttpWebRequest)
    	request.Method = "GET"
    	request.Accept = "text/html, application/xhtml+xml, */*"
    	request.UserAgent = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)"
    	request.ContentType = "application/x-www-form-urlencoded"
    	request.CachePolicy = New RequestCachePolicy(RequestCacheLevel.NoCacheNoStore)
    	'No caching
    	Dim response As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse)
    	If response.StatusCode = HttpStatusCode.OK Then
    		Dim stream As New StreamReader(response.GetResponseStream())
    		Dim html As String = stream.ReadToEnd()
    		'<timestamp time=\"1395772696469995\" delay=\"1395772696469995\"/>
    		Dim time As String = Regex.Match(html, "(?<=\btime="")[^""]*").Value
    		Dim milliseconds As Double = Convert.ToInt64(time) / 1000.0
    		dateTime__1 = New DateTime(1970, 1, 1).AddMilliseconds(milliseconds).ToLocalTime()
    	End If
    
    	Return dateTime__1
    End Function
    Link to original code:

    https://stackoverflow.com/questions/...m-the-internet
    Disclaimer: When code is given for example - it is merely a example.




    Unless said otherwise indicated - All Code snippets advice or otherwise that I post on this site, are expressly licensed under Creative Commons Attribution 4.0 International Please respect my copyrights.

  6. #6
    Frenzied Member jdc20181's Avatar
    Join Date
    Oct 2015
    Location
    Indiana
    Posts
    1,175

    Re: Trial version that expires after X amount of Days

    I agree with the comment about people dont like stuff that dont work without internet, but doing so is a neccessity if its a trial. You could advertise NO internet needed with Premium version..
    Disclaimer: When code is given for example - it is merely a example.




    Unless said otherwise indicated - All Code snippets advice or otherwise that I post on this site, are expressly licensed under Creative Commons Attribution 4.0 International Please respect my copyrights.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width