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
157 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 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now