A Working 30 Day Trial Application

The article about writing a try before you buy feature into your software got a lot of interest. The astute reader will notice that all I really showed in that article was how to tell if the copy of the registration DLL was the same one that you shipped with the product. The manual shows how to check to see if your application is valid. It's a good base to start from.

At least one reader was motivated to write me though and ask for more. The reader, Hari, wanted to see what a real 30 day trial would look like. Since that's a fairly common mode for a lot of software, I implemented a crude version of it. You can find the complete source code attached to this story. If you want to actually build it you'll need to have the registration DLL installed on your system. The trial version should be sufficient for this demo.

Limitations

I built the demo with the idea of visibility in mind. When the application is run for the first time it looks for a file called trialreg.conf. If the file isn't found the program writes a special serial number (using the serial API) that marks it as a trial with the date that it was first run, as well as a registration key that we can use to prevent tampering with that serial number.

The astute reader will notice right away that renewing the trial period is as simple as deleting trialreg.conf and getting a new serial number. In production you would want to write this information to a registry entry instead. In your uninstall you should take pains to leave the registration information in place. This isn't fool proof, but it would catch the bulk of users. Hiding this information in some obscure place might not be a bad idea either, and that will trip up everyone but those who are absolutely determined to circumvent the trial period--people you weren't going to be getting money from anyway.

If anybody has even more ingenious ways to deal with the problem please feel free to post them in the comments or bring it up on the support forum. I considered modifying the executable itself, with some kind of flag at the end of the file to indicate that the program had already been registered once, but there are file locking issues that have to be dealt with.

AttachmentSize
30-day-demo.c6 bytes
ยป