Go Premium for a chance to win a PS4. Enter to Win

x
?
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
Medium Priority
?
172 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
  • 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 2000 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Screencast - Getting to Know the Pipeline
Suggested Courses

916 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