Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

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
?
170 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 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
Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

 
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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

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.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Suggested Courses

722 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