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
169 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
Percona Monitoring and Management and Grafana

Proactive monitoring is vital to a highly-available environment. We have a quick start guide on Experts Exchange for Grafana users.

 
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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

623 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