views:

150

answers:

5

Hi,

I saw this question in a forum about how an application can be developed that can keep track of the installation date and show trail period expired after 30 days of usage. The only constraint is not to use the external storage of any kind.

Question: How to achieve this?

Thanks
Bala

--Edit
I think its easy to figure out the place to insert a question work. Anyway, I will write the question clearly. "external storage" means don't use any kind of storage like file, registry, network or anything. You only have your program.

A: 

If you can't use any external storage at all (not even config files or anything like that), you would need to code it into the app itself so the app's main method (or some method) checks if the current date is less than some expiration date. Part of your installer could actually compile that code on the fly and then it would be set to the installation date. This could be easily defeated by reinstalling the app, but then again, it's not realistic to have no external storage either.

Jeff Storey
Or moving the calendar back, but good idea.
MusiGenesis
A: 

I think the only way to do this generally would be to have your application spawn something off in a separate process that would continue to run and keep track of the date/time even if the main application were closed. When it was restarted, it would then connect to the running process to see if the trial period had expired.

Of course, this would only work if the computer was never restarted and the user never hunted down your spawned process and killed it, which is pretty unlikely. If your application does not do anthing IO-related (file system, registry, something on the network etc.), then a simple restart will wipe away anything that you've done.

So, to summarize: it's not really possible.

MusiGenesis
musi - consider the context: interview question.
Sky Sanders
+5  A: 

Use the file-modified date of the file containing the program as the installation date.

Doug Currie
But the user could do this and keep using the software. I think there are hackers out there who try this kind of trivial stuff.
Algorist
+ as close as it gets
Sky Sanders
@Algorist - puhleeeze - don't be passive aggressive with your context and requirements, it is just annoying. ;-) Interview questions are not intended to produce code, they are intended to expose problem solving skills.
Sky Sanders
@Sky Sanders: Thanks for your suggestions.
Algorist
A: 

I don't know if this is possible, as most work I've done has been with embedded systems in which I don't even need to touch the operating system. But would the following be possible?

When compiling your program, leave some extra space at the end (say, 8 bytes), all set to 0. When your application is run, it fetches those bytes and if they're all 0, replaces them with the current time (That's the part I'm not sure about. Does the OS let you do that? If not, there might be some work-arounds using multiple processes.), otherwise, if the time difference is greater than 30 days, it notifies the user that the trial period has ended.

Of course, that method would be vulnerable to resetting the system clock.

Wallacoloo
The application's installer could embed the date+time in the file (avoiding any permission problems when run as a normal user), then the application reads it on startup. The application could also compare the machine's time with a time source on the Internet to detect if the clock was set back. Although, even this would fail if someone changed a little bit of the code so that instead of checking if the time has expired, simply always returns the value that says there's more time remaining. The most you'll be able to do is make the code such a mess no body wants to look at it.
Kitsune
I thought of this, but will the OS let you modify the program on disk from the same process? Could this lead to some recursive nature of program. can we spawn other process and get this thing done?
Algorist
+1  A: 

I like Doug Currie's idea of the file-modification date. But if the application is downloaded from the web, every night at midnight it gets relinked with new initialized data containing the new expiration date. Then any binary downloaded that day expires on the date given.

If you like, sign the date with a private key so it can't be hacked. Include a public key in the app and decrypt the date. If not correctly signed, hasta la vista, baby.

Norman Ramsey
Where do you propose to store the exemplar?
Sky Sanders
@Sky: Oh, good one. But the problem does say "install date" which implies there is an exemplar or master copy to be installed. I'm sure that's allowed to be stored *somewhere* (perhaps on a server) and updated nightly.
Norman Ramsey