Solved

Creating a edit control on a dialog box applications that prints "this software has been run   X times"

Posted on 2004-09-17
6
168 Views
Last Modified: 2013-11-20
How can I do the above, that is, keep track of the number of times an executable has been opened as do many demo versions?

Thank you
0
Comment
Question by:iportu
[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 13

Expert Comment

by:SteH
ID: 12084489
You need to store the number of times the program was opened in some known but hidden place. This could be a registry key for example. On startup this key is read and incremented and written back. To display its value in an edit box you need to format the integer into a CString:

CString csRes;
csRes.Format ("This software has been used %d times", nRuns);

and set is as window text:

c_ceRuns.SetWindowText (csRes); // c_ceRuns being a control variable for that edit box.
0
 

Author Comment

by:iportu
ID: 12084534
Thank you SteH, but how do I store the number of times the program has been opened in a registry key?
0
 
LVL 13

Accepted Solution

by:
SteH earned 500 total points
ID: 12084624
You need to have write acces to that part of the registry!
RegOpenKeyEx gives you acces to a special subkey of
HKEY_CLASSES_ROOT
HKEY_CURRENT_CONFIG
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE or
HKEY_USERS
with KEY_WRITE accesability at least. Then you create your key and store a value using
RegCreateKeyEx () // creates or opens the key
RegQueryValueEx () // read the value
RegSetValueEx () // set a new value.

and last you close the key using
RegCloseKey ()

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!

 
LVL 19

Expert Comment

by:mrwad99
ID: 12085374
>> RegOpenKeyEx gives you acces to a special subkey of...

Would it not be easier to use CWinApp::WriteProfileInt ()
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_cwinapp.3a3a.writeprofileint.asp)

and CWinApp::GetProfileInt()

(http://msdn.microsoft.com/library/en-us/vclib/html/_mfc_CWinApp.3a3a.GetProfileInt.asp)

?

0
 
LVL 13

Expert Comment

by:SteH
ID: 12085451
Since the technique is normally used by shareware the approach using the std location for profiles will be too easy to track. Remove the key and you can reuse the program against the will of the author. The general approach lets you easier hide the location of the key (if regmon is not in use during installation). Thats why I proposed the general approach.
0
 

Author Comment

by:iportu
ID: 12100702
Thank you SteH, I got it working
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Title # Comments Views Activity
Is it possible to combine several text files into one big one? (redhat v5 enterprise) 4 115
Perl Awk Need Help 3 150
post4 challenge 28 122
how to split multiple lines delimiter : 8 133
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Suggested Courses

734 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