Click here to Skip to main content
13,625,600 members
Click here to Skip to main content
Add your own
alternative version


49 bookmarked
Posted 15 Oct 2002

Shareware registration dialog

, 15 Oct 2002
Rate this:
Please Sign up or sign in to vote.
Dialog that manages shareware application registration and trial period


RegDialog is an MFC-based dialog that will help you manage shareware application registrations. When the shareware application is started for the first time; information about the company, application's name, version number, trial period and starting date is created in the registry. Every next time the user starts the application, RegDialog appears with information about number of days left to use and offers registration code entering or to continue unregistered. After the trial period is finished user can only enter registration code and after the shareware application is registered, RegDialog will no more appear. Of course user can register application during the trial period also. Reinstalling the shareware application will not "help" because the information about the starting date is left in the registry and "new" application will just continue to count trial period days. The first time user starts shareware application, RegDialog will not appear - that is because user should first see and test the application and at that time I think it is not the right time to send him messages about days left to use or about continuing unregistered. So keep this in mind when you start demo application or your application with RegDialog - RegDialog will show when you start your application the 2nd time! Also, because RegDialog is working with the system registry please see the note below.

How to use it?

  • Create or open your existing code.
  • In VC++ menu select Project->Add to Project->Components and Controls...
  • Browse to RegDialog.ogx (download and select it.
  • In applications main class insert #include "RegDialog.h"
  • In the same class, in InitInstance() function insert:
  • ...
     CRegDialog regDlg;
  • Of course, replace "MyCompany" with something you choose or have as adequate name.
  • In RegDialog.cpp modify part specified as "App specific data":
    ///////////// App Specific Data !!!  /////////////
    int DaysLimit = 30;
    long KeyCode  = 12345678;
    CString Version = "1.1";


    • DaysLimit is the number of days application will work unregistered.
    • KeyCode is the code that user must enter to register application.
    • Version is the string used to avoid newer versions of your software getting registered if older version was.

All this, you can see in the demo project you can download from this page (

Few things you need to know

The OnAskcode() function of the CRegDialog class is the place you should put what will happen when the user presses the "Register" button. It can be some dialog with price and hyperlink to registration site, some register.exe file or "send mail" link. KeyCode is long type variable. If you need KeyCode with letters included modify the code so it writes string types instead of int types to registry database (see the note below!). Code can be easily modified to calculate user's registration code from letters of his name instead of using KeyCode variable compiled in the application


Because this class is working with the system registry - the important OS database - be careful if you change the code. If you don't know exactly what registry functions are doing do not change them! Just use the class as it is and it will work. See MSDN for information and help about the registry.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Ivan Markovic
Software Developer
Yugoslavia Yugoslavia
Likes C++, templates, patterns, sarmas and loves Luka and Jelena

You may also be interested in...

Comments and Discussions

Questionhow to... Pin
Ivan Markovic17-Oct-02 13:48
sussIvan Markovic17-Oct-02 13:48 
AnswerRe: how to... Pin
Piccinano12-May-03 21:11
memberPiccinano12-May-03 21:11 
GeneralImprovement! Pin
mrAndy16-Oct-02 23:09
membermrAndy16-Oct-02 23:09 
GeneralNumber of days in Registry Pin
Rolando E. Cruz-Marshall16-Oct-02 14:08
memberRolando E. Cruz-Marshall16-Oct-02 14:08 
GeneralRe: Number of days in Registry Pin
mrAndy16-Oct-02 22:51
membermrAndy16-Oct-02 22:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web04 | 2.8.180712.1 | Last Updated 16 Oct 2002
Article Copyright 2002 by Ivan Markovic
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid