Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing trial version software for Win2K?

Status
Not open for further replies.

inetd

Technical User
Jan 23, 2002
115
HK
I want to write a trial version program that can be run on Win2K. The program can run for 100 times. During each start up, the program should write a counter in some place, e.g. registry or a file in some location. However if the program is installed on Win2k by administrator and run by any normal user, it can't write the counter in registry nor files in installed directory, winnt, winnt\system.

How can I solve this kind of problem?
How the other well known software do that?

Thanks.
 
I suppose that is why some programs use a date to disable itself. When the Admin puts the program in, an install date is put into the reg. Each time the program is run, it compares the current date to the date in the reg. After some many days, the program will stop working or disable certain features. One thing to note, you may want to make the reg entry not look like a date so someone can't change the program's reg date easily.



James P. Cottingham

When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity.
[tab][tab]Albert Einstein explaining his Theory of Relativity to a group of journalists.
 
I know this doesn't answer your question completely, but it's added info. Haha, see post on Password. Use the encode/decode routine there to store the date in the reg. You need to think about a few things when writing a test program.

I would recommend not writing a trial version that displays to the user "27 days left" or whatever. When there's 1 day left, they'll try to crack the software. Just don't say anything. Run the software like normal, then on day 30 they go to run the program and you disable it completely. By disabling it completely, I mean altering a segment of the program itself.

Here's what I would do. Write the program as usual. Then, after compiling, write a series of bytes to the end of the file to mark it as having been run the first time. Let's see...I'm thinking this up as I go.

1) Compile the program. Don't run it.
2) When you run the program for the first time, read the last 11 bytes of itself
3) Determine if bytes 0 through 9 match a pre-determined pattern (0xFF143F34F454F0376DAC).
4) If they match, then read the 11th byte in and see if it is true or false.
5) If they don't match, write the pattern to the end of the file, then make the last byte of the file true.
6) Now, when you are ready to disable the file (i.e. 30 days passed), then write the last byte in the file to false.

This allows you to use the following logic:

pattern exists last byte set Program runs
no no yes
yes yes yes
yes no no

Then they couldn't just hack into the registry and change the date and everything works fine again. Now this does mean they could just replace your executable with an earlier version.

Note: You might also want to just encode the date into the executable file as well. Compare that date to the one in the registry, and if they aren't equal, set the last byte in the executable to false.

Where to put the date in the registry is the question...and I don't know the answer. It would be nice if there was a hidden part of the registry that only your installed program could access. All I can say is put the date in there, and they may change it (but the above example could catch that).

BUT what a lot of programmers do is utilize several different approaches. Write to the registry, write to the executable, AND write to a separate file hidden in some nonsense named directory under windows somewhere. While doing all of this, all of the dates are encrypted.

The easiest way is to just use the internet (if your program requires the internet anyway, it's the only way). Connect to the server and verify that you still have authority to run the program, and what options you may use. That's all great until your server goes down...then you have to decide do you automatically grant them access or do you deny them use of the software. What if they just stopped their internet connection...

Think about it...

Now to your question. I'm not sure how, but you'll have to grant priviledges to all users for writing to the file and to that registry location. You could instead of writing to HKEY_CURRENT_USER write to HKEY_LOCAL_MACHINE. And instead of writing to the WINNT directory, write to a different directory that the users have priviledges to already. I'm sure there are some OS routines to allow the admin to give priviledges to all users.

Good luck,
Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top