Demo Counter

First - using Borland 5.2 & OWL
I would like to allow useage of a program for a specified number of (uses , days) unless it's registered.
How could one go about programming this in? I've heard REGISTRY entries work but using OWL am leary about playing around in the registry in case I screw it this in fact a real danger??
Help or suggestions would be appreciated (alos pseu code or snippet if possible).
Who is Participating?
alexoConnect With a Mentor Commented:
Create or open a registry key for your program in HKEY_LOCAL_MACHINE\Software\MyCompany\MyProduct using:

    HKEY hKey; // Save it!
    DWORD disposition;
        HKEY_LOCAL_MACHINE, "Software\\MyCompany\\MyProduct",
        &hKey, &disposition);

Create or write a value:

    DWORD counter = 0;
    RegSetValueEx(hKey, "Counter", 0, REG_DWORD, counter, sizeof counter);
Read the value:

    DWORD counter = 0;
    DWORD len, type;
    RegQueryValueEx(hKey, "Counter", NULL, &type, (LPBYTE)&counter, &len);



Now: in your program RegCreateKeyEx() the key, RegQueryValueEx() the counter, increment it and RegSetValueEx() the data.
That is a danger off course...
Registry data is stored in the files system.dat and user.dat in the windows directory. Windows it self maintains backup copies of these files, system.da0 and user.da0
The backup files are updates if windows boots successfully. It may be worthwhile to keep your own backup copies, since not every fault in the registry will cause windows not to boot.

You can, in the event of a screw-up, restore the backups.
dooley090698Author Commented:
I understand the dangers of the registry and was looking for some way of (even using the registry) to count the number of times (or days).
Could you give me some ideas on how to implement this..
Never miss a deadline with

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

dooley090698Author Commented:
Thank you VERY much - that explains a LOT and clears up some of my confusion.
Great to have access to this knowledge base.
dooley090698Author Commented:
Once again thanks for the help
Any time!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.