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