Solved

Demo Counter

Posted on 2000-03-21
6
182 Views
Last Modified: 2010-04-02
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 up..is this in fact a real danger??
Help or suggestions would be appreciated (alos pseu code or snippet if possible).
Txs
0
Comment
Question by:dooley090698
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 7

Expert Comment

by:KangaRoo
ID: 2640518
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.
0
 

Author Comment

by:dooley090698
ID: 2640813
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..
0
 
LVL 11

Accepted Solution

by:
alexo earned 100 total points
ID: 2643496
Create or open a registry key for your program in HKEY_LOCAL_MACHINE\Software\MyCompany\MyProduct using:

    HKEY hKey; // Save it!
    DWORD disposition;
    RegCreateKeyEx(
        HKEY_LOCAL_MACHINE, "Software\\MyCompany\\MyProduct",
        0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
        &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);

Finally:

   RegCloseKey(hKey);


Now: in your program RegCreateKeyEx() the key, RegQueryValueEx() the counter, increment it and RegSetValueEx() the data.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:dooley090698
ID: 2643894
Thank you VERY much - that explains a LOT and clears up some of my confusion.
Great to have access to this knowledge base.
0
 

Author Comment

by:dooley090698
ID: 2643899
Once again thanks for the help
0
 
LVL 11

Expert Comment

by:alexo
ID: 2648106
Any time!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question